Hello,
I'm having trouble setting up a simple scene with an ortho2D
projection. I have looked at many examples (osghud, osgpick, osgmovie,
...) and I can't see what I'm doing wrong. It should be simple, but I
feel I'm running in circles. Here's basically what I'm doing.
First, I create a quad like this:
osg::Geometry* polyGeom = osg::createTexturedQuadGeometry(
osg::Vec3( 0.0f, 0.0f, 0.0f),
osg::Vec3(1280.0f, 0.0f, 0.0f),
osg::Vec3( 0.0f, 1024.0f, 0.0f),
0.0f, 0.0f,
(useTextureRectangle ? 1280.0f : 1.0f),
(useTextureRectangle ? 1024.0f : 1.0f));
osg::Geode* geode = new osg::Geode();
geode->addDrawable(polyGeom);
geode->getOrCreateStateSet()->setMode(
GL_LIGHTING, osg::StateAttribute::OFF);
It's my understanding that this creates a quad with corners (0,0,0),
(1280,0,0), (1280,1024,0) and (0, 1024,0) and where the texcoords
match (depending on the use of textureRectangle or texture2D).
This geode is given to the viewer.
Then, the viewer's projection and view matrices are set like so:
viewer.getCamera()->setProjectionMatrixAsOrtho2D(0.0, 1280, 0.0, 1024);
viewer.getCamera()->setViewMatrix(osg::Matrix::identity());
viewer.getCamera()->setViewport(0, 0, 1280, 1024);
The rest of the code is based on the osgviewer application, so right
after setting the matrices the viewer is run.
return viewer.run();
The problem is that I don't see the quad. If I comment out my
"setProjectionMatrixAs..." line (therefore the viewer sets its
projection according to the geode's bbox automatically) then I see the
quad, but when it's set to ortho2D it isn't displayed. Also, moving
around the scene with the mouse doesn't change anything.
My ultimate goal is to display the quad fullscreen with perfect 1-to-1
mapping between screen pixels and texels on the quad. Looking at
straight OpenGL tutorials on this, it should work, and after trying
lots of things to achieve this in OSG it seems that I am not getting
closer at all. Any help would be appreciated.
Thanks in advance,
--
______________________________________________________
Jean-Sebastien Guay [EMAIL PROTECTED]
http://whitestar02.webhop.org/
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/