[osg-users] OpenSceneGraph with Qt multiple windowing problem

Robert Osfield robert.osfield at gmail.com
Thu Sep 20 08:51:57 PDT 2007


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