I was using glXWaitVideoSyncSGI() in a Pre Draw Callback (the place I need it 
to be) to get the current Frame Count from the video card. I've recently found 
out that this Frame Count number from this function can be incorrect when I'm 
reading textures from the GPU to the CPU or writing textures from the CPU to 
the GPU. In particular, I would see about 100ms between calls to 
glXWaitVideoSyncSGI but the frame counter returned would either be consecutive 
(i.e. no missed frames) or skipping one number (i.e. one missed frame). I'm 
running at 60 Hz (16ms frames).

Therefore, I'm now trying to use glXQueryFrameCountNV() (I have G-SYNC II card 
and have enabled Frame Lock). It would appear I need to call this when I have a 
valid Graphics Context. I assume this isn't normally the case in a 
PreDrawCallback.  I've had to do this in the PreDrawCallback:
            if (camera.getGraphicsContext() &&
                camera.getGraphicsContext()->valid() &&
                camera.getGraphicsContext()->isRealized())
            {
                osg::GraphicsContext* gc = 
const_cast<osg::GraphicsContext*>(camera.getGraphicsContext());
                gc->makeCurrent();
            }
followed by my call to glXQueryFrameCountNV().

However, to make this work, I've had to set my osgViewer's threading model to 
SingleThreaded. If I don't do this I usually see a "Xlib: unexpected async 
reply (sequence 0x6a)!" message followed by a segmentation fault.

What am I doing wrong? Is there some better way to do something in a valid 
graphics context when not in a draw callback?

Paul P.


      
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to