To render OSG in an existing OGL viewport, you still need to create an OSG 
viewer because that is what kicks off the OSG traversals when the frame() 
method is called. You also need to manage (i.e. Push and Pop) OGL state 
correctly since OSG and OGL share the same render context so that you don't 
trash your existing OGL rendering state.

Anyway, here's basically what you do to setup and render OSG stuff in an OGL 
viewport/window. This uses CompositeViewer so you could render multiple OSG 
viewports embedded inside an OGL window...:)

osgViewer::CompositeViewer *viewer = new osgViewer::CompositeViewer();
osgViewer::GraphicsWindowEmbedded *gw = new osgViewer::GraphicsWindow(ogl_x, 
ogl_y, ogl_w, ogl_h); 

osgViewer::View *view = new osgViewer::View;
view->getCamera->setGraphicsContext(gw);
view->getCamera->setViewport(osg_x, osg_y, osg_w, osg_h); // somewhere inside 
OGL viewport/window that has origin in LL corner
.
.
// set rest of the view OSG camera state and matrices as usual
.
.
view->setSceneData(scenegraph);
viewer->addView(view);
viewer->realize();
.
.

// do this during rendering loop for each OGL frame...
PushOGLState();
viewer->frame(); // render OSG embedded viewport in OGL window
PopOGLState();

Hope this helps...

Shayne[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50153#50153





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to