Hi all,
I hope this will help many in the future, I figured out the missing piece for
this case.
Code:
void MyWidget::paintGL()
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glPushAttrib(GL_ALL_ATTRIB_BITS);
glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
glShadeModel(GL_SMOOTH);
osg::State *state = getCamera()->getGraphicsContext()->getState();
state->reset();
state->apply(_lastStateSet.get());
frame();
// this was the missing step:
glViewport(0, 0, width(), height());
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd(getCamera()->getViewMatrix().ptr());
glMatrixMode(GL_PROJECTION);
glLoadMatrixd(getCamera()->getProjectionMatrix().ptr());
// here you can draw in OSG's 3D space
getCamera()->getGraphicsContext()->getState()->captureCurrentState(*_lastStateSet);
glPopAttrib();
glPopClientAttrib();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
// here you can draw in Qt's 2D space
}
I'm actually not sure if everything here is needed, but this works.
Cheers
--
Bence
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=10908#10908
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org