Hello Robert, and everybody,
I meet a strange problem when intergrate my osg code to an existing opengl
project.
I searched the mailing list to know I should warpper osg render code with
glPush(pop)Attrib,but this seems not enough for me .
PLease take a look the following codes......
the api calls between "/*opengl drawings*/" doesn't draws anything if I put
"/*4 lines of osg sceneview render code*/" before it.When I put osg code after
those
opengl calls , It draws out ,but opengl draws has been occluded by osg
drawis....
It almost make me mad....... seems it is not so easy to intergrate osg with
opengl projects.......Help....Help....Help.....Thanks ....Thanks.....
// OpenGL has been setup before here and
SceneView::getRenderStage()->setClearMask(GL_NONE);has been called to avoid
clear buffers
static int distance=500;
// main loop here
while (msg.message!=WM_QUIT)
{
if(PeekMessage(&msg, NULL, 0, 0,PM_REMOVE))
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
glViewport(0,0,1024,768);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45,1024.0/768.0,1,300000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,distance,0,0,0,0,1,0);
//////////////////////////////////////////////////////////////////////////
glClearColor(0.0f,0.0f,1.0f,1.0f);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
/*4 lines of osg render code*/
//draw osg stage
glPushAttrib(GL_ALL_ATTRIB_BITS);
//////////do SceneView::update and SceneView::cull here
StageInterface::Update();
//do SceneView::draw here
StageInterface::Render();
glPopAttrib();
/*4 lines of osg render code*/
//the problem is: the codes below doesn't draws anything.........
//but if I remove the 4 lines of code above everything runs ok
// I also tried to move those 4 lines of code to the mark:
"also tried insert here" just before swap buffer,everything draws out
but opengl drawings all has been occluded by osg drawings......strange
/*opengl drawings*/
////draw point
glPointSize(200);
glBegin(GL_POINTS);
glColor3f(1, 0, 0);
glVertex3f(-100,-100,100);
glEnd();
glPushMatrix();
//drawsphere
//glScale(0.1,0,0);
glutSolidSphere(50,100,10);
glPopMatrix();
/*opengl drawings*/
/********************also tried insert here ***********************/
SwapBuffers(m_hDC);
}
_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/