[osg-users] Multiple GraphicsContexts

John Donovan john.donovan at embryonicstudios.com
Tue Sep 11 06:42:21 PDT 2007

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 =

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 =

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.


This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

More information about the osg-users mailing list