Hi Frank,

So, I'm sure it's probably not possible to create a render context without 
having a window of some kind. My guess is that (in Windows, at least), creating 
a render context requires a Win32 device context, and that getting a device 
context requires an HWND. So, I suppose my only option would be to create an 
invisible window. If possible, I think it would be acceptable to create an 
invisible window, and then just glReadPixels from the back buffer or something.

No, on Windows as well as on Linux and MacOS X it is possible to create a context without a window. The trick is to create a pbuffer instead of a graphics context, i.e. set pbuffer = true in the traits structure you pass to osg::GraphicsContext::create().

Perhaps currently you don't even call this, and the graphics context (by default a GraphicsWindow, i.e. a window containing a context) is created for you by the viewer, but if after creating your viewer you create a graphics context with pbuffer = true and assign it to the viewer's (or view's) camera, then it won't create the default one.

See the code in osgconv (applications/osgconv/osgconv.cpp) for an example of this.

Once you have that, you can use your viewer as before, but it will render in the pbuffer (offscreen) and if you're so inclined, you can read back the result of the render after the frame is done into CPU memory and do what you want with it. You are right that it will be slow... AFAIK, WPF has no inherent support for an OpenGL widget like Qt does, but if performance is not a concern then you probably don't even need this.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.g...@cm-labs.com
                               http://www.cm-labs.com/
                    http://whitestar02.dyndns-web.com/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to