Hi,
is it possible to first draw objects in perspective mode, and then switch this view with gluOrtho2D and draw other objects, like controlbars etc…
in my RenderScene procedure, after drawing 3D, i would switch like this:
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, viewWidth, viewHeight, 0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glEnable(GL_SCISSOR_TEST);
// i write my drawing code here
glDisable(GL_TEXTURE_2D);
glPopAttrib();
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
why doesn’t this work?
anybody?
wang the stuff to switch between them in some display lists (I’m using Persp & Ortho). Do this when your window is resized
{
glDeleteLists(Persp,1);
glDeleteLists(Ortho,1);
Persp = glGenLists(1);
Ortho = glGenLists(1);
if( h==0 ) h = 1;
glNewList(Persp,GL_COMPILE);
glViewport(0, (GLsizei) 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(55.0, w/h , 0.01, 500 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEndList();
glNewList(Ortho,GL_COMPILE);
glViewport(0, (GLsizei) 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, w, h, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEndList();
}
Once thats done, your display func should be something of the form…
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
glLoadIdentity()
glCallList(Persp);
//draw 3d stuff
glCallList(Ortho);
//draw 2d gubbins
}