You can declare and register a PostDrawCallback with the camera class to do OGL rendering. It will get called after the OSG rendering traversal...
void PushOSG_GL_State()
{
// since OSG and OGL share the same render context, push OGL state
used by OSG
glPushAttrib(GL_ALL_ATTRIB_BITS);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glMatrixMode(GL_TEXTURE);
glPushMatrix();
}
void PopOSG_GL_State()
{
// pop it back off when done with our explicit OGL rendering...
glMatrixMode(GL_TEXTURE);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopAttrib();
}
struct OGLPostDrawCallback : public osg::Camera::DrawCallback
{
OGLPostDrawCallback(){}
virtual void operator () (const osg::Camera& camera) const
{
PushOSG_GL_State();
// OpenGL rendering happens here...
renderOGL();
PopOSG_GL_State();
}
};
.
.
.
view->getCamera()->setPostDrawCallback(new OGLPostDrawCallback);
.
.
.
I'm sure there are other ways to do this but this is what we're doing. It
works fine.
Hope this helps...
-Shayne
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Mukund
Keshav
Sent: Tuesday, January 25, 2011 1:09 PM
To: [email protected]
Subject: Re: [osg-users] OpenSceneGraph with glut support
Hi Robert,
im really sorry, i somehow missed out on your post on my first read. Thanks
for the detailed explanation. Well im a student and looking at the vastness
of OSG, i felt it would require quite a lot of time. So, i was looking for
support from the lower level APIs.
Thanks
...............
Hi Shayne,
> Our OpenGL rendering
> is in a wrapper which happens in a post draw callback. This seems to work
> fine. The key is in state management since OSG and OpenGL share the same
> render context.
Could you please elaborate with some links or small examples? i did not
quite get you.
Thanks a lot!
Mukund
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35963#35963
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

