[osg-users] Multiple GraphicsContexts

Robert Osfield robert.osfield at gmail.com
Tue Sep 11 06:54:38 PDT 2007


BTW, is there a reason why you aren't just using a single context and
a FBO RTT Camera?

On 9/11/07, Robert Osfield <robert.osfield at gmail.com> wrote:
> Hi John,
>
> I can only guess that you first need to realize the window before you
> can share it.
>
> For an example of sharing contexts see src/osg/GraphicsContext.cpp and
> look for the createCompileContext() code segment.
>
> Robert.
>
> On 9/11/07, John Donovan <john.donovan at embryonicstudios.com> wrote:
> >
> > Robert Osfield wrote:
> > > If you wish to reuse texture objects generated by one context then you
> > > need to share the various contexts with each other.  You can set this
> > > via the GraphicsContext::Traits::sharedContext variable.
> >
> >
> > Ah! OK, that makes sense. But I am having problems with it...
> > I have the following:
> > ref_ptr<GraphicsContext::Traits> traits_rtt = new GraphicsContext::Traits;
> > traits_rtt->x = 500;
> > traits_rtt->y = 880;
> > traits_rtt->width = totalWidth;
> > traits_rtt->height = vpHeight;
> > traits_rtt->windowDecoration = false;
> > traits_rtt->doubleBuffer = true;
> > traits_rtt->sharedContext = 0;
> > ref_ptr<GraphicsContext> gc_rtt =
> > GraphicsContext::createGraphicsContext(traits_rtt.get());
> >
> > ref_ptr<GraphicsContext::Traits> traits_view = new GraphicsContext::Traits;
> > traits_view->x = 500;
> > traits_view->y = 800;
> > traits_view->width = totalWidth;
> > traits_view->height = vpHeight;
> > traits_view->windowDecoration = true;
> > traits_view->doubleBuffer = true;
> > traits_view->sharedContext = gc_rtt.get();
> > ref_ptr<GraphicsContext> gc_view =
> > GraphicsContext::createGraphicsContext(traits_view.get());
> >
> > Then I have a viewer with a camera rendering to a texture, and a viewer
> > rendering a textured quad to a window.
> > But when I call Viewer::frame() on the viewer that renders to the window, I get
> > the following error messages:
> >
> > Windows Error #170: [Screen #0] GraphicsWindowWin32::realizeImplementation() -
> > Unable to share OpenGL context. Reason: The requested resource is in use.
> >
> > Error: [Screen #0] GraphicsWindowWin32::makeCurrentImplementation() - Window
> > not realized; cannot do makeCurrent.
> >
> > Are there any examples I can work off? I've tried a search for sharedContext in
> > the OSG project, but I just get the implementation code, not any example code.
> > Incidentally, I've upgraded to 2.1.9 without a hitch.
> >
> > -J
> >
> >
> >
> > ______________________________________________________________________
> > This email has been scanned by the MessageLabs Email Security System.
> > For more information please visit http://www.messagelabs.com/email
> > ______________________________________________________________________
> > _______________________________________________
> > osg-users mailing list
> > osg-users at lists.openscenegraph.org
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
>



More information about the osg-users mailing list