[osg-users] OpenSceneGraph with Qt multiple windowing problem

Alberto Luaces aluaces at udc.es
Fri Sep 21 01:34:23 PDT 2007


Hi Robert,

thanks for the information about the contexts. Now my task seems to me easier 
that I thought. I'm subclassing from osgViewer::GraphicsWindow, so I think 
I'll have to take account for the context IDs and the osg::State, as the 
osgwxviewer does (though only for one view). Anyways, I have the aid of the 
osgViewer::GraphicsWindowEmbedded class to copy some of its implementation 
details.

Alberto

El Thursday 20 September 2007 17:51:57 Robert Osfield escribió:
> Hi Alberto,
>
> On 9/20/07, Alberto Luaces <aluaces at udc.es> wrote:
> > I'm a bit confused about the naming.  What do you mean by "graphics
> > context"? An OpenGL one or an osg::GraphicsContext?
>
> osg::GraphicsContext maps directly to an OpenGL context so there
> should not be any confusion.
>
> > I ask because currently I have a wxWidgets application with two views of
> > the same scene. Each view is attached to an osgViewer::GraphicsWindow
> > which in turn controls its wxGLcanvas. The two wxGLcanvas were created
> > with a common OpenGL context, so all the GL objects as display lists,
> > textures... are shared. Each osgViewer::GraphicsWindow has one
> > osg::State.
>
> A sharing OpenGL contexts doesn't mean actually sharing of the
> context, its just sharing some data between contexts, so you don't
> have a "common OpenGL context", you have two separate OpenGL contexts
> that are sharing display lits/texture objects etc.
>
> Each GraphicsWindow "is a" GraphicsContext which maps directly to a
> single OpenGL graphics context.  Each OpenGL graphics context has its
> own state machine which is mapped by a single osg::State object -
> which you'll find on the GraphicsContext.
>
> Sharing of display lists/texture objects between contexts on the OSG
> just requires you to set the State::ContextID to same value.  If the
> GraphicsWindow implementation is set up correctly then it'll
> automatically assign the same ContextID for each of the seperate
> osg::State objects.
>
> > In summary I have
> >
> > 2 wxGLCanvas ( sharing GL objects, one only common wxGLContext)
> > 2 osgViewer::GraphicsWindow ( which are in fact 2 osg::GraphicContext)
> > 2 osgViewer::View (I'm using osgViewer::CompositeViewer)
> > 2 osg::State (not sure if only one would do)
> >
> > If, in addition, I wanted to show two more views of a new different
> > scene, should I do the same as before (creating 2 GraphicsWindows, 2
> > Views, 2 States and connect them to the 2 wxGLCanvas with a new shared
> > OpenGL context) and attaching the Views to the existing CompositeViewer
> > or should I create a new CompositeViewer and attach the 2 new Views
> > there?
>
> Ideally a single CompositeViewer should be used per app, and the
> various Views and associate GraphicsWindow managed according to your
> needs.  The osg::State objects should all be managed as an
> implementation detail, you shouldn't need to concern yourself with it.
>
> Robert.






More information about the osg-users mailing list