Hi Robert,
Thanks for the quick reply. My app is single threaded. I have implemented a
work around using an explicit makeCurrent on the viewer's current camera's
graphicsContext. I could not see a simple way of dirtying the viewer in a
way that did not cause an erroneous releaseContext on a context that was not
really current.
I flagged this up because it seems rather a bold assumption to make that a
single instance of an osgViewer object is in control of all the OpenGL
rendering contexts that might be in use by an application. Am I correct in
my assumption that an application uses more than one osgViewer object will
also suffer from the same problems.
I have a vague recollection that this may have been already discussed, if so
my apologies.
Roger
P.S. just an aside, is there any reason for this duplication
inline void releaseContext()
{
if (_currentContext.valid() && _currentContext->valid())
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:osg-users-
> [EMAIL PROTECTED] On Behalf Of Robert Osfield
> Sent: 10 September 2007 14:21
> To: Public OpenSceneGraph Users discussion list.
> Subject: Re: [osg-users] Problem with makeCurrent implementation in
> osgViewer
>
> Hi Roger,
>
> If your app makes the context current in a different thread than
> osgViewer has for rendering to the same graphics context without
> osgViewer knowing about the fact that the context has been stolen from
> underneath it then it is not suprising you'll find problems.
>
> You'll need to either add an explicit makeCurrent to make sure the
> context is current, or dirty the Viewer in some way so it doesn't
> assume that the context is current anymore.
>
> Robert.
>
> On 9/10/07, Roger James <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> > 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;
> >
> >
> >
> > releaseContext();
> >
> >
> >
> > if (gc && gc->valid() && gc->makeCurrent()) _currentContext
> =
> > gc;
> >
> > }
> >
> >
> >
> > 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
> > this.
> >
> >
> >
> > I have got a work around by unconditionally calling makeCurrent before
> > calling frame in the idle loop.
> >
> >
> >
> > Robert, is my analysis correct?
> >
> >
> >
> > Roger
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-
> openscenegraph.org
> >
> >
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org