Ignore:
Timestamp:
04/30/08 13:24:45 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2669 r2670  
    123123} 
    124124 
     125 
    125126// reimplemented here so that we can snap the error windows 
    126127float QtGlRendererBuffer::GetPixelError(int &pvsSize) 
     
    128129        MakeCurrent(); 
    129130         
    130         cout << "stencil: " << format().stencil() << endl; 
    131         cout << "depth: " << format().depth() << endl; 
    132         cout << "rgba: " << format().rgba() << endl; 
    133         cout << "double: " << format().doubleBuffer() << endl; 
     131        if (0) 
     132        { 
     133                cout << "stencil: " << format().stencil() << endl; 
     134                cout << "depth: " << format().depth() << endl; 
     135                cout << "rgba: " << format().rgba() << endl; 
     136                cout << "double: " << format().doubleBuffer() << endl; 
     137        } 
     138 
     139        ++ mCurrentFrame; 
    134140 
    135141        float pErrorPixels = -1.0f; 
     
    144150                return -1.0f; 
    145151 
    146         KdNode::NewMail2(); 
    147         Intersectable::NewMail(); 
    148  
    149         ObjectPvs pvs; 
    150  
    151152        bool evaluateFilter; 
    152153        Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluateFilter", evaluateFilter); 
     154 
     155        ObjectPvs pvs; 
    153156 
    154157        if (!evaluateFilter)  
     
    169172        if (mSnapErrorFrames) 
    170173        { 
    171  
    172174                GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0}; 
    173175                GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 
    174176                GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; 
    175177 
    176                 GLfloat light_position[] =  //{278.0f, 548.8f,279.0f, 1.0f}; 
    177                 {0.f,0.f,0.f, 1.0f}; 
     178                //GLfloat light_position[] =  {278.0f, 548.8f,279.0f, 1.0f}; 
     179                GLfloat light_position[] =  {0.f,0.f,0.f, 1.0f}; 
    178180 
    179181                glEnable(GL_LIGHT0);  
     
    208210        glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);  
    209211 
    210          
     212        KdNode::NewMail2(); 
     213        Intersectable::NewMail(); 
     214 
     215KdNode::NewMail2(); 
     216        Intersectable::NewMail(); 
     217        KdNode::NewMail2(); 
     218        Intersectable::NewMail(); 
     219 
    211220        // render pvs once 
    212221        RenderPvs(pvs); 
     
    228237        query->BeginQuery(); 
    229238 
     239        ++ mCurrentFrame; 
     240 
    230241        RenderScene(); 
    231242 
    232243        query->EndQuery(); 
    233244        glDisable(GL_STENCIL_TEST);  
    234  
    235  
    236         // reenable other state 
    237         int wait = 0; 
    238         while (0 && !query->ResultAvailable())  
    239                 wait ++; 
    240245         
    241246        pixelCount = query->GetQueryResult(); 
    242247 
     248        pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 
     249 
    243250        if (pixelCount > 0)  
    244251        { 
    245252                cout << "vc id: " << viewcell->GetId() << " pvs: " << pvsSize << " pc: " << pixelCount << endl; 
    246         } 
    247  
    248         pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 
    249  
    250  
    251         if (mSnapErrorFrames && (pixelCount > 0))  
    252         { 
    253                 glReadBuffer(GL_BACK); 
    254                 //glReadBuffer(GL_FRONT); 
    255  
    256                 char filename[256]; 
    257                 sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 
    258                 QImage im = toImage(); 
    259                 string str = mSnapPrefix + filename; 
    260                 QString qstr(str.c_str()); 
    261  
    262                 im.save(qstr, "PNG"); 
    263                 if (0) { //0 && mFrame == 1543) { 
    264                         int x,y; 
    265                         int lastIndex = -1; 
    266                         for (y=0; y < im.height(); y++) 
    267                                 for (x=0; x < im.width(); x++) { 
    268                                         QRgb p = im.pixel(x,y); 
    269                                         int index = qRed(p) + (qGreen(p)<<8) + (qBlue(p)<<16); 
    270                                         if (qGreen(p) != 255 && index!=0) { 
    271                                                 if (index != lastIndex) { 
    272                                                         //                              Debug<<"ei="<<index<<" "; 
    273                                                         lastIndex = index; 
    274                                                 } 
    275                                         } 
    276                                 } 
    277                 } 
    278                  
    279  
    280 #if 0 
    281                 mUseFalseColors = false; 
    282  
    283                 glPushAttrib(GL_CURRENT_BIT); 
    284                 glColor3f(0, 1, 0); 
    285                  
    286                 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    287                 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    288                 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 
    289  
    290                 KdNode::NewMail2(); 
    291                 Intersectable::NewMail(); 
    292  
    293                 RenderPvs(pvs); 
    294  
    295                 glFinish(); 
    296  
    297                 mUseForcedColors = false; 
    298  
    299                 im = toImage(); 
    300                 sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 
    301                 str = mSnapPrefix + filename; 
    302                 qstr = str.c_str(); 
    303                 im.save(qstr, "PNG"); 
    304                  
    305                 glPopAttrib(); 
    306 #endif 
     253         
     254                if (mSnapErrorFrames)  
     255                { 
     256                        glReadBuffer(GL_BACK); 
     257                        //glReadBuffer(GL_FRONT); 
     258 
     259                        ////////////// 
     260                        //-- output error visualization 
     261 
     262                        char filename[256]; 
     263                        sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 
     264                        QImage im = toImage(); 
     265                        string str = mSnapPrefix + filename; 
     266                        QString qstr(str.c_str()); 
     267 
     268                        im.save(qstr, "PNG"); 
     269 
     270 
     271                        /////////// 
     272                        //-- output computed pvs 
     273 
     274                        mUseFalseColors = false; 
     275 
     276                        glPushAttrib(GL_CURRENT_BIT); 
     277                        glColor3f(0, 1, 0); 
     278 
     279                        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     280                        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 
     281 
     282                        KdNode::NewMail2(); 
     283                        Intersectable::NewMail(); 
     284 
     285                        ++ mCurrentFrame; 
     286                        // render pvs once 
     287                        RenderPvs(pvs); 
     288 
     289                        mUseForcedColors = false; 
     290 
     291                        im = toImage(); 
     292                        sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 
     293                        str = mSnapPrefix + filename; 
     294                        qstr = str.c_str(); 
     295                        im.save(qstr, "PNG"); 
     296 
     297                        glPopAttrib(); 
     298                } 
    307299        } 
    308300 
     
    497489 
    498490 
    499 void QtGlRendererWidget::PreparePvs2(const ObjectPvs &pvs) 
     491void QtGlRendererWidget::PreparePvs(const ObjectPvs &pvs) 
    500492{ 
    501493        int indexBufferSize = 0; 
    502494         
    503         // super hack: mal not working with multiple threads 
     495        // hack: mail not working with multiple threads 
    504496        KdNode::NewMail2(); 
    505         //Intersectable::NewMail(); 
    506497 
    507498        mPvsSize = pvs.GetSize(); 
     
    546537 
    547538 
    548  
    549  
    550 void QtGlRendererWidget::RenderPvs() 
     539void QtGlRendererWidget::VisualizePvs() 
    551540{ 
    552541        if (mUseVbos)  
     
    600589#else 
    601590         
    602                 PreparePvs2(viewcell->GetPvs()); 
     591                PreparePvs(viewcell->GetPvs()); 
    603592                emit PvsUpdated(); 
    604593 
    605594#endif 
    606  
    607595 
    608596                // Render PVS 
     
    662650 
    663651        // Render PVS 
    664         RenderPvs(); 
     652        VisualizePvs(); 
    665653 
    666654        glEnable(GL_STENCIL_TEST);  
     
    696684        int pixelCount = query->GetQueryResult(); 
    697685        pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 
     686         
    698687        if (0) cout << "error pixels=" << pixelCount << endl; 
    699688 
     
    826815} 
    827816 
    828 void 
    829 QtGlRendererWidget::paintGL() 
     817 
     818void QtGlRendererWidget::paintGL() 
    830819{ 
    831820        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     
    843832                { 
    844833                        glColor3f(0.6f, 0.6f, 0.6f); 
    845                         RenderPvs(); 
     834                        VisualizePvs(); 
    846835                } 
    847836 
Note: See TracChangeset for help on using the changeset viewer.