Ignore:
Timestamp:
01/14/06 01:41:57 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp

    r535 r538  
    2121 
    2222GlRendererWidget *rendererWidget = NULL; 
     23GlDebuggerWidget *debuggerWidget = NULL; 
    2324 
    2425 
     
    446447{ 
    447448  static int glList = -1; 
    448   if (glList != -1) { 
    449         glCallList(glList); 
    450   } else { 
     449  if (glList == -1) 
     450  { 
    451451        glList = glGenLists(1); 
    452         glNewList(glList, GL_COMPILE_AND_EXECUTE); 
     452        glNewList(glList, GL_COMPILE); 
    453453        ObjectContainer::const_iterator oi = mObjects.begin(); 
    454454        for (; oi != mObjects.end(); oi++) 
     
    456456        glEndList(); 
    457457  } 
     458   
     459  glCallList(glList); 
     460   
    458461  return true; 
    459462} 
     
    565568GlRendererWidget::paintGL() 
    566569{ 
    567   RenderErrors(); 
    568   mFrame++; 
     570        RenderErrors(); 
     571         
     572        mFrame++; 
    569573} 
    570574 
     
    780784        GenQueries((int)beam.mViewCells.size()); 
    781785 
    782         // now check whether any backfacing polygon would pass the depth test 
     786        // now check whether any backfacing polygon would pass the depth test? 
    783787        glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 
    784788        glDepthMask(GL_FALSE); 
     
    799803 
    800804        // at this point, if possible, go and do some other computation 
    801         glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    802         glDepthMask(GL_TRUE); 
    803         glEnable(GL_CULL_FACE); 
     805 
     806        queryIdx = 0; 
     807        unsigned int pixelCount; 
    804808 
    805809        // 8. The number of visible pixels is the number of sample rays which see the source 
    806         //    object from the corresponding viewcell -> rember these values for later update 
    807         //   of the viewcell pvs - or update immediatelly? 
    808  
    809         //  In general it is not neccessary to rember to extract all the rays cast. I hope it 
     810        //    object from the corresponding viewcell -> remember these values for later update 
     811        //   of the viewcell pvs - or update immediately? 
     812 
     813        for (vit = beam.mViewCells.begin(); vit != vit_end; ++ vit) 
     814        { 
     815                // fetch queries 
     816                glGetOcclusionQueryuivNV(sQueries[queryIdx ++], 
     817                                                                 GL_PIXEL_COUNT_NV, 
     818                                                                 &pixelCount); 
     819 
     820                Debug << "visble pixels: " << pixelCount << endl; 
     821        } 
     822         
     823 
     824        //  In general it is not neccessary to remember to extract all the rays cast. I hope it 
    810825        // would be sufficient to gain only the intergral statistics about the new contributions 
    811826        // and so the rss tree would actually store no new rays (only the initial ones) 
     
    815830        // (new viewcell has been discovered) or relative contribution greater than a threashold ...  
    816831 
     832        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     833        glDepthMask(GL_TRUE); 
     834        glEnable(GL_CULL_FACE); 
     835 
     836 
    817837        cgGLDisableProfile(sCgFragmentProfile); 
    818838        glDisable(GL_TEXTURE_2D); 
     
    838858} 
    839859 
     860 
    840861void GlRendererBuffer::SetupProjectionForViewPoint(const Vector3 &viewPoint,  
    841862                                                                                                 const Beam &beam,  
     
    855876                          viewPoint.x, viewPoint.y, viewPoint.z,  
    856877                          up.x, up.y, up.z); 
    857 }                          
     878}                
     879 
     880   
     881  
     882 
     883/***************************************************************/ 
     884/*             GlDebuggerWidget implementation                             */ 
     885/***************************************************************/ 
     886 
     887 
     888GlDebuggerWidget::GlDebuggerWidget(QWidget *parent, GlRendererBuffer *buf) 
     889      : QGLWidget(QGLFormat(QGL::SampleBuffers), parent), mRenderBuffer(buf) 
     890{ 
     891        // create the pbuffer 
     892    //pbuffer = new QGLPixelBuffer(QSize(512, 512), format(), this); 
     893    timerId = startTimer(20); 
     894    setWindowTitle(("OpenGL pbuffers")); 
     895} 
     896 
     897 
     898GlDebuggerWidget::~GlDebuggerWidget() 
     899{ 
     900        mRenderBuffer->releaseFromDynamicTexture(); 
     901        glDeleteTextures(1, &dynamicTexture); 
     902         
     903        DEL_PTR(mRenderBuffer); 
     904} 
     905 
     906 
     907void GlDebuggerWidget::initializeGL() 
     908{ 
     909        glMatrixMode(GL_PROJECTION); 
     910        glLoadIdentity(); 
     911 
     912        glFrustum(-1, 1, -1, 1, 10, 100); 
     913        glTranslatef(-0.5f, -0.5f, -0.5f); 
     914        glTranslatef(0.0f, 0.0f, -15.0f); 
     915        glMatrixMode(GL_MODELVIEW); 
     916 
     917        glEnable(GL_CULL_FACE); 
     918        initCommon(); 
     919        initPbuffer(); 
     920 
     921} 
     922 
     923 
     924void GlDebuggerWidget::resizeGL(int w, int h) 
     925{ 
     926        glViewport(0, 0, w, h); 
     927} 
     928 
     929 
     930void GlDebuggerWidget::paintGL() 
     931{ 
     932        // draw a spinning cube into the pbuffer.. 
     933        mRenderBuffer->makeCurrent(); 
     934        //mRenderBuffer->SampleBeamContributions(); 
     935        glFlush(); 
     936 
     937    // rendering directly to a texture is not supported on X11, unfortunately 
     938    mRenderBuffer->updateDynamicTexture(dynamicTexture); 
     939    
     940    // ..and use the pbuffer contents as a texture when rendering the 
     941    // background and the bouncing cubes 
     942    makeCurrent(); 
     943    glBindTexture(GL_TEXTURE_2D, dynamicTexture); 
     944    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     945 
     946    // draw the background 
     947    glMatrixMode(GL_MODELVIEW); 
     948    glPushMatrix(); 
     949    glLoadIdentity(); 
     950    glMatrixMode(GL_PROJECTION); 
     951    glPushMatrix(); 
     952    glLoadIdentity(); 
     953 
     954        glPopMatrix(); 
     955        glMatrixMode(GL_MODELVIEW); 
     956        glPopMatrix(); 
     957} 
     958 
     959 
     960void GlDebuggerWidget::initPbuffer() 
     961{ 
     962        // set up the pbuffer context 
     963    mRenderBuffer->makeCurrent(); 
     964        initCommon(); 
     965 
     966        glViewport(0, 0, mRenderBuffer->size().width(), mRenderBuffer->size().height()); 
     967        glMatrixMode(GL_PROJECTION); 
     968        glLoadIdentity(); 
     969        glOrtho(-1, 1, -1, 1, -99, 99); 
     970        glTranslatef(-0.5f, -0.5f, 0.0f); 
     971        glMatrixMode(GL_MODELVIEW); 
     972        glLoadIdentity(); 
     973 
     974        glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); 
     975 
     976        // generate a texture that has the same size/format as the pbuffer 
     977    dynamicTexture = mRenderBuffer->generateDynamicTexture(); 
     978 
     979        // bind the dynamic texture to the pbuffer - this is a no-op under X11 
     980        mRenderBuffer->bindToDynamicTexture(dynamicTexture); 
     981        makeCurrent(); 
     982} 
     983 
     984void GlDebuggerWidget::initCommon() 
     985{ 
     986        glEnable(GL_TEXTURE_2D); 
     987        glEnable(GL_DEPTH_TEST); 
     988 
     989        glClearColor(1.0f, 1.0f, 1.0f, 1.0f); 
     990} 
Note: See TracChangeset for help on using the changeset viewer.