Hi
the usual practice is to place opengl calls after all attribs are saved,
after OpenGL code is finished - they all are restored
glPushAttrib( GL_ALL_ATTRIB_BITS );
glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glMatrixMode(GL_TEXTURE);
glPushMatrix();
//your OpenGL code here
....
glMatrixMode(GL_TEXTURE);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopClientAttrib();
glPopAttrib();
Regards
Sergey
On Mon, Dec 29, 2014 at 2:42 PM, Marcin Kolny <[email protected]>
wrote:
> Hi,
>
> I've got a following code:
>
>
> Code:
>
> viewer = new osgViewer::Viewer;
> viewer->setCameraManipulator(new osgGA::TrackballManipulator);
> window = viewer->setUpViewerAsEmbeddedInWindow(0,0,716,572);
> viewer->getCamera()->setClearMask(GL_DEPTH_BUFFER_BIT);
>
> // ...
>
> glMatrixMode (GL_PROJECTION);
> glLoadIdentity ();
>
> GLfloat verts[] = { -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f };
> GLfloat texcoords[] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f };
>
> glEnable (GL_TEXTURE_2D);
> glBindTexture (GL_TEXTURE_2D, texture_id);
> glClientActiveTexture (GL_TEXTURE0);
>
> glEnableClientState(GL_VERTEX_ARRAY);
> glEnableClientState (GL_TEXTURE_COORD_ARRAY);
>
> glVertexPointer (2, GL_FLOAT, 0, &verts);
> glTexCoordPointer (2, GL_FLOAT, 0, &texcoords);
> glDrawArrays (GL_TRIANGLE_FAN, 0, 4);
>
> glDisableClientState(GL_TEXTURE_COORD_ARRAY);
>
> glDisable(GL_TEXTURE_2D);
>
> osg::Geometry* geom = new osg::Geometry;
> osg::Vec3Array* vertices = new osg::Vec3Array;
> vertices->push_back(osg::Vec3d(0, 30, 0));
> vertices->push_back(osg::Vec3d(width, 30, 0));
> geom->setVertexArray(vertices);
> geom->addPrimitiveSet(new osg::DrawArrays(GL_LINES,0,vertices->size()));
>
> viewer->setSceneData(geom);
> viewer->realize();
>
> if (viewer.valid()) viewer->frame();
>
>
>
>
>
> It loads texture with identifier texture_id, draw it (using pure opengl),
> and later I try to draw line on this texture. Unfortunately, when I draw
> this line, my image is becoming darker. When I remove line
>
> Code:
>
> viewer->setSceneData(geom);
>
>
>
> output image has normal colours, but obviously I don't have my line there.
> What's wrong with my code, and why my image is darker? I attach also two
> images (it's not a whole image, but only a part of it) to show you the
> difference.
>
> Thank you!
>
> Cheers,
> Marcin[/code]
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=62200#62200
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org