Hi Sophie.

OK, we are probably getting bit nearer to understanding the approach you
are gunning for.  The OSG by default computes the near/far range of the
scene in the view frustum - this range is then used to optimize the
projection matrix.  While fine for most users needs in your case when you
are mixing two scenes within each other you'll need to switch this feature
off to make sure both are using the same projection matrix.  You can do
this via in the viewer setup:


viewer.getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);

Another thing you'll need to be mindful of is state in the non OSG OpenGL
code leaking into the OSG, and from the OSG into the non OSG OpenGL code.
The glPushAttrib around the OSG calls will insulate the non OSG OpenGL code
from the OSG, but not the OSG.

Robert.


On 17 March 2015 at 15:13, Sophie Audonneau <
sophie.audonne...@etu.univ-lorraine.fr> wrote:

> Hi,
>
> Sorry, I was not sure of what you meant by type of viewer.
> I only know that the window is defined in a QGLWidget.
>
> I have already tried something with osgViewer::GraphicsWindowEmbedded.
>
>     glPushAttrib( GL_ALL_ATTRIB_BITS );
>     glMatrixMode( GL_PROJECTION );
>     glPushMatrix();
>     glMatrixMode( GL_TEXTURE );
>     glPushMatrix();
>     glMatrixMode( GL_MODELVIEW );
>     glPushMatrix();
>     glDisable(GL_LIGHTING);
>     glDisable( GL_BLEND ) ;
>
>     //get openGL current parameters
>     GLint viewParams[4];
>     glGetIntegerv( GL_VIEWPORT, viewParams );
>
>     //set up viewer
>     viewer_.getCamera()->setGraphicsContext(gc_);
>
>
> viewer_.setUpViewerAsEmbeddedInWindow(viewParams[0],viewParams[1],viewParams[2]
> ,viewParams[3]);
>
>     viewer_.setSceneData(obj_->get_root());
>
>     GLdouble glMat[16];
>
>     glGetDoublev( GL_PROJECTION_MATRIX, glMat );
>     viewer_.getCamera()->setProjectionMatrix( osg::Matrix(glMat) );
>     glGetDoublev( GL_MODELVIEW_MATRIX, glMat );
>     viewer_.getCamera()->setViewMatrix( osg::Matrix(glMat) );
>
>     viewer_.frame();
>
>     glMatrixMode( GL_TEXTURE );
>     glPopMatrix();
>     glMatrixMode( GL_PROJECTION );
>     glPopMatrix();
>     glMatrixMode( GL_MODELVIEW );
>     glPopMatrix();
>     glPopAttrib();
>     glEnable( GL_BLEND );
>
> I can display OpenSceneGraph objects in the software but in a viewer that
> is superimposed on the original one.
>
> Thanks,
>
> Sophie
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=63135#63135
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to