[osg-users] The importance of using Camera::setDrawBuffer()+setReadBuffer() in application setup

Robert Osfield robert.osfield at gmail.com
Wed Mar 7 01:53:36 PST 2018

Hi All,

A recent investigation into a bug a user was seeing in their
application revealed that some applications that use 3rd party
windowing toolkits aren't setting up the viewer Camera's correctly,
and I've traced this back to the examples that the OSG provides.  To
fix these I checked in the followinig commit that patches the various
osgviewer* examples:


These fixes are now checked into the OpenSceneGraph-3.4 branch and
master.  The changes are all in form:

        // set the draw and read buffers up for a double buffered
window with rendering going to back buffer

This explicitly tells the OSG that you wish it to render to the back
buffer, rather than just leave it to OpenGL defaults.  Not having
these calls causes problems when you do RTT work where the draw/read
buffer state has to be toggled between different states.  You can
think this of a classic uninitialized variable issue - if you don't
set the value you can get undefined results.

If you are using native osgViewer windowing it's likely that you won't
need to make any changes as the code in osgViewer for setting up
various viewer configurations do the neccessary
setDrawBuffer+setReadBuffer() calls.  If you are are creating the
graphics context and setting up the Camera's yourself then you'll need
to above calls.

If you are using a Pixel Buffer then you'd set the values to GL_FRONT,
or if you are using stereo buffer then you'll won't to use


More information about the osg-users mailing list