Ignore:
Timestamp:
01/24/07 04:11:29 (18 years ago)
Author:
bittner
Message:

glrenderer updates

File:
1 edited

Legend:

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

    r2048 r2049  
    9696  unsigned int pixelCount; 
    9797 
    98  
     98   
    9999  ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint); 
     100   
    100101  if (viewcell == NULL) 
    101102        return 0.0f; 
     
    166167   
    167168   
    168   if (mSnapErrorFrames && pErrorPixels >= 0.01f) { 
     169  if (0 && mSnapErrorFrames && pErrorPixels >= 0.01f) { 
    169170         
    170171        char filename[256]; 
     
    448449{ 
    449450  float pErrorPixels = -1.0f; 
    450  
    451   glReadBuffer(GL_BACK); 
    452    
    453   mUseFalseColors = true; 
    454  
    455   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    456    
    457   double eq[4]; 
    458   eq[0] = mSceneCutPlane.mNormal.x; 
    459   eq[1] = mSceneCutPlane.mNormal.y; 
    460   eq[2] = mSceneCutPlane.mNormal.z; 
    461   eq[3] = mSceneCutPlane.mD; 
    462    
    463   if (mCutScene) { 
    464         glClipPlane(GL_CLIP_PLANE0, eq); 
    465     glEnable(GL_CLIP_PLANE0); 
    466   } 
    467    
    468   if (mDetectEmptyViewSpace)  
    469         glEnable( GL_CULL_FACE ); 
    470   else 
    471         glDisable( GL_CULL_FACE ); 
    472  
    473   ObjectContainer::const_iterator oi = mObjects.begin(); 
    474   for (; oi != mObjects.end(); oi++) 
    475         RenderIntersectable(*oi); 
    476  
    477   ViewCell *viewcell = NULL; 
    478  
    479   QImage im1, im2; 
    480   QImage diff; 
    481    
    482   if (viewcell) { 
    483         // read back the texture 
    484         im1 = grabFrameBuffer(true); 
    485          
    486         RenderPvs(); 
    487  
    488         // read back the texture 
    489         im2 = grabFrameBuffer(true); 
    490          
    491         diff = im1; 
    492         int x, y; 
    493         int errorPixels = 0; 
    494          
    495         for (y = 0; y < im1.height(); y++) 
    496           for (x = 0; x < im1.width(); x++) 
    497                 if (im1.pixel(x, y) == im2.pixel(x, y)) 
    498                   diff.setPixel(x, y, qRgba(0,0,0,0)); 
    499                 else { 
    500                   diff.setPixel(x, y, qRgba(255,128,128,255)); 
    501                   errorPixels++; 
    502                 } 
    503         pErrorPixels = ((float)errorPixels)/(im1.height()*im1.width()); 
    504   } 
    505  
    506   // now render the pvs again 
     451   
    507452  SetupCamera(); 
    508   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    509   mUseFalseColors = false; 
    510    
    511   oi = mObjects.begin(); 
    512   for (; oi != mObjects.end(); oi++) 
    513         RenderIntersectable(*oi); 
    514  
    515   // now render im1 
    516   if (viewcell) { 
    517         if (0 && mTopView) { 
    518           mWireFrame = true; 
    519           RenderIntersectable(viewcell); 
    520           mWireFrame = false; 
    521         } 
    522          
    523         // init ortographic projection 
    524         glMatrixMode(GL_PROJECTION); 
    525         glPushMatrix(); 
    526          
    527         glLoadIdentity(); 
    528         gluOrtho2D(0, 1.0f, 0, 1.0f); 
    529          
    530         glMatrixMode(GL_MODELVIEW); 
    531         glLoadIdentity(); 
    532          
    533         bindTexture(diff); 
    534          
    535         glPushAttrib(GL_ENABLE_BIT); 
    536         glEnable( GL_ALPHA_TEST ); 
    537         glDisable( GL_CULL_FACE ); 
    538         glAlphaFunc( GL_GREATER, 0.5 ); 
    539          
    540         glEnable( GL_TEXTURE_2D ); 
    541         glBegin(GL_QUADS); 
    542          
    543         glTexCoord2f(0,0); 
    544         glVertex3f(0,0,0); 
    545          
    546         glTexCoord2f(1,0); 
    547         glVertex3f( 1, 0, 0); 
    548          
    549         glTexCoord2f(1,1); 
    550         glVertex3f( 1, 1, 0); 
    551          
    552         glTexCoord2f(0,1); 
    553         glVertex3f(0, 1, 0); 
    554         glEnd(); 
    555          
    556         glPopAttrib(); 
    557          
    558         // restore the projection matrix 
    559         glMatrixMode(GL_PROJECTION); 
    560         glPopMatrix(); 
    561         glMatrixMode(GL_MODELVIEW); 
    562   } 
    563  
    564   glDisable(GL_CLIP_PLANE0); 
    565    
     453  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 
     454 
     455  glPushAttrib(GL_ENABLE_BIT); 
     456 
     457  glStencilFunc(GL_EQUAL, 0x0, 0x1); 
     458  glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);  
     459 
     460  mUseForcedColors = true; 
     461 
     462  glColor3f(0.0f, 0.8f, 0.2f); 
     463 
     464  //    // Render PVS 
     465  RenderPvs(); 
     466   
     467  glEnable(GL_STENCIL_TEST);  
     468   
     469  //  mUseFalseColors = true; 
     470   
     471  glDisable(GL_LIGHTING); 
     472   
     473  OcclusionQuery *query = mOcclusionQueries[0]; 
     474  query->BeginQuery(); 
     475   
     476  SetupCamera(); 
     477 
     478  glColor3f(1.0f, 0.0f, 0.0f); 
     479   
     480  RenderScene(); 
     481 
     482  mUseForcedColors = false; 
     483 
     484  query->EndQuery(); 
     485   
     486  glDisable(GL_STENCIL_TEST); 
     487  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     488 
     489  glPopAttrib(); 
     490 
     491  // reenable other state 
     492  //  int wait=0; 
     493  //  while (!query.ResultAvailable()) { 
     494  //    wait++; 
     495  //  } 
     496 
     497  int pixelCount = query->GetQueryResult(); 
     498  pErrorPixels = ((float)pixelCount)/(GetWidth()*GetHeight()); 
     499  cout<<"error pixels="<<pixelCount<<endl; 
     500 
    566501  mRenderError = pErrorPixels; 
     502 
    567503  return pErrorPixels; 
    568504} 
     
    719655        if (!ok) 
    720656          break; 
     657         
    721658        if (sscanf(text.toAscii(), "%f %f %f", &mViewPoint.x, &mViewPoint.y, &mViewPoint.z) == 3) { 
    722           updateGL(); 
     659          text.sprintf("%f %f %f", mViewDirection.x, mViewDirection.y, mViewDirection.z); 
     660          text = QInputDialog::getText(this, 
     661                                                                   "Enter a direction", 
     662                                                                   "", 
     663                                                                   QLineEdit::Normal, 
     664                                                                   text, 
     665                                                                   &ok); 
     666          if (!ok) 
     667                break; 
     668          if (sscanf(text.toAscii(), "%f %f %f", &mViewDirection.x, 
     669                                 &mViewDirection.y, &mViewDirection.z) == 3) { 
     670                updateGL(); 
     671          } 
     672          break; 
    723673        } 
    724         break; 
    725674  } 
    726675  default: 
     
    10581007   
    10591008  glEnable(GL_CULL_FACE); 
    1060   //glDisable(GL_CULL_FACE); 
    10611009  glCullFace(GL_FRONT); 
     1010 
     1011  glDisable(GL_CULL_FACE); 
    10621012  double eq[4]; 
    10631013  eq[0] = mSceneCutPlane.mNormal.x; 
     
    10891039        //      Mesh *m = vc->GetMesh(); 
    10901040 
    1091  
    10921041        RgbColor c; 
    10931042 
     
    10971046        } else { 
    10981047          //      const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 
    1099           const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().GetSize() / (float)maxPvs); 
     1048          const float importance = 5.0f*mTransferFunction * 
     1049                ((float)vc->GetPvs().GetSize() / (float)maxPvs); 
    11001050          c = RgbColor(importance, 1.0f - importance, 0.0f); 
    11011051        } 
Note: See TracChangeset for help on using the changeset viewer.