Ignore:
Timestamp:
01/17/08 23:56:46 (16 years ago)
Author:
bittner
Message:

occlusion query bugfix

File:
1 edited

Legend:

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

    r2611 r2612  
    101101QtGlRendererBuffer::GetPixelError(int &pvsSize) 
    102102{ 
    103         float pErrorPixels = -1.0f; 
     103 
     104  float pErrorPixels = -1.0f; 
    104105 
    105106 
     
    135136        Intersectable::NewMail(); 
    136137        while (it.HasMoreEntries())  
    137         { 
     138          { 
    138139                RenderIntersectable(it.Next()); 
    139         } 
     140          } 
    140141 
    141142 
     
    147148 
    148149        OcclusionQuery *query = mOcclusionQueries[0]; 
    149  
    150  
     150         
    151151        query->BeginQuery(); 
    152152 
     
    157157        query->EndQuery(); 
    158158        glDisable(GL_STENCIL_TEST);  
     159 
    159160        // reenable other state 
    160161        //  int wait=0; 
     
    162163        //      wait++; 
    163164        //  } 
    164  
     165         
    165166 
    166167        pixelCount = query->GetQueryResult(); 
     
    170171 
    171172        if (mSnapErrorFrames && pErrorPixels >= 0.01f) { 
    172                 glReadBuffer(GL_BACK); 
    173  
    174                 char filename[256]; 
    175                 sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 
    176                 QImage im = toImage(); 
    177                 string str = mSnapPrefix + filename; 
    178                 QString qstr(str.c_str()); 
    179  
    180                 im.save(qstr, "PNG"); 
    181                 if (1) { //0 && mFrame == 1543) { 
    182                         int x,y; 
    183                         int lastIndex = -1; 
    184                         for (y=0; y < im.height(); y++) 
    185                                 for (x=0; x < im.width(); x++) { 
    186                                         QRgb p = im.pixel(x,y); 
    187                                         int index = qRed(p) + (qGreen(p)<<8) + (qBlue(p)<<16); 
    188                                         if (qGreen(p) != 255 && index!=0) { 
    189                                                 if (index != lastIndex) { 
    190                                                         //                              Debug<<"ei="<<index<<" "; 
    191                                                         lastIndex = index; 
    192                                                 } 
    193                                         } 
    194                                 } 
    195                 } 
    196  
    197  
    198                 mUseFalseColors = false; 
    199                 glPushAttrib(GL_CURRENT_BIT); 
    200                 glColor3f(0,1,0); 
    201                 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    202                 SetupCamera(); 
    203                 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    204  
    205                 // Render PVS 
    206                 Intersectable::NewMail(); 
    207  
    208                 ObjectPvsIterator it = pvs.GetIterator(); 
    209                 for (; it.HasMoreEntries(); )  
    210                 { 
    211                         RenderIntersectable(it.Next()); 
    212                 } 
    213  
    214                 im = toImage(); 
    215                 sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 
    216                 str = mSnapPrefix + filename; 
    217                 qstr = str.c_str(); 
    218                 im.save(qstr, "PNG"); 
    219                 glPopAttrib(); 
    220         } 
    221  
     173          glReadBuffer(GL_BACK); 
     174           
     175          char filename[256]; 
     176          sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 
     177          QImage im = toImage(); 
     178          string str = mSnapPrefix + filename; 
     179          QString qstr(str.c_str()); 
     180           
     181          im.save(qstr, "PNG"); 
     182          if (1) { //0 && mFrame == 1543) { 
     183                int x,y; 
     184                int lastIndex = -1; 
     185                for (y=0; y < im.height(); y++) 
     186                  for (x=0; x < im.width(); x++) { 
     187                        QRgb p = im.pixel(x,y); 
     188                        int index = qRed(p) + (qGreen(p)<<8) + (qBlue(p)<<16); 
     189                        if (qGreen(p) != 255 && index!=0) { 
     190                          if (index != lastIndex) { 
     191                                //                              Debug<<"ei="<<index<<" "; 
     192                                lastIndex = index; 
     193                          } 
     194                        } 
     195                  } 
     196          } 
     197           
     198           
     199          mUseFalseColors = false; 
     200          glPushAttrib(GL_CURRENT_BIT); 
     201          glColor3f(0,1,0); 
     202          glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     203          SetupCamera(); 
     204          glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     205           
     206          // Render PVS 
     207          Intersectable::NewMail(); 
     208           
     209          ObjectPvsIterator it = pvs.GetIterator(); 
     210          for (; it.HasMoreEntries(); )  
     211                { 
     212                  RenderIntersectable(it.Next()); 
     213                } 
     214           
     215          im = toImage(); 
     216          sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 
     217          str = mSnapPrefix + filename; 
     218          qstr = str.c_str(); 
     219          im.save(qstr, "PNG"); 
     220          glPopAttrib(); 
     221        } 
     222         
    222223        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    223  
     224         
    224225        return pErrorPixels; 
    225226} 
Note: See TracChangeset for help on using the changeset viewer.