[osg-users] Problem with makeCurrent implementation in osgViewer
roger at beardandsandals.co.uk
Mon Sep 10 06:08:36 PDT 2007
In my previous posts "[osg-users] Help - trying to get a wxWidgets
implementation ofosgViewer::Viewer working!" I described a problem with the
viewer scene not being updated.
I have now tracked this down to the implementation of makeCurrent in
osgViewer. My application renders an osg scene in its main window using osg
but not using osgViewer. osgViewer is used to render an additional scene in
a pop up window. If I disable the rendering of the main scene whilst the pop
up is being displayed all works fine. However if I allow the main window
rendering loop to run the pop up window is drawn once and then not updated.
This is because the OpenGL rendering context has been set back that of the
main window and this change is not being detected. The following check in
makeCurrent only makes a change if the osg::GraphicsContext the viewer knows
about is not the current osg::GraphicsContext the viewer knows. This does
not wok is the current rendering context is not encapsulated in an
osg::Graphics context that this viewer object knows about.
inline void makeCurrent(osg::GraphicsContext* gc)
if (_currentContext==gc) return;
if (gc && gc->valid() && gc->makeCurrent()) _currentContext =
This used to work in SimpleViewer which I assume made an unconditional
context switch on each frame. This means that the current implementation
will not work if an application uses OpenGL contexts that are not
encapsulated by an osg::GraphicsContext. I assume that it also means that
even if the context is encapsulated it will have to be on the list for a
particular viewer object for things to work, although I have not checked
I have got a work around by unconditionally calling makeCurrent before
calling frame in the idle loop.
Robert, is my analysis correct?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the osg-users