Original Post
let me explain my problem then give you a little code... my problem originally start when drawing my terrain as a sphere and the min and max was about a range from -6000 to 6000. i had to lower the difference in my gluPerspective call so i wouldnt get Z-fighting(i am using gluLookAt instead of glTranslatef). so originally my call was: gluPerspective(45.0f,(GLfloat)w/(GLfloat)h,0.1f,20000.0f); now the call in the reshape function is: gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,1000.0f,20000.0f); this solved my depth buffer problem for the data, but this now brings up a new problem. i have things drawn on the screen like a legend and some text drawn in ortho mode. using the new gluPerspective call these dont 'show' up. so what i decided to do was in my class where i draw the ortho stuff(text, 2D legend etc) is to add the code for the original gluPerspective calls: ...... ...... //draw stuff here glPopMatrix(); to make sure that my terrain back in the main drawscene shows up before i draw the terrain i set the gluPerspective back to the new change as is here: ok so now this works i say to myself, i run it and behold i can see my 2D stuff in ortho and my terrain but i notice another problem. somehow the depth buffer has been 'corrupted'? the 2D stuff should be in front of the terrain, but actually it looks like everything is being drawn backwards.. i.e. the terrain(3D) covers the 2D stuff when it gets moved closer to the screen... so do you have any other suggestions? did i take the wrong approach from the very beginning when changing the gluPerspective call for the 2D stuff? i would appreciate your input.. thanks!
//**********in class that draws all the 2D ortho stuff************
glPushMatrix();
glClear(GL_DEPTH_BUFFER_BIT);
glViewport(0,0,w,h); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
setWidthHeight(w, h);
gluPerspective(45.0f,(GLfloat)w/(GLfloat)h,0.1f,20000.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity();
//***********draw_2D stuff here***************
...........
...........
glPopMatrix();
//********main drawScene*************
//*******object->class(draw2D stuff) -- this is where the code is called from above..*******
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
gluPerspective(45.0f,(GLfloat)1280/(GLfloat)1024, 1000.0f,20000.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity();
gluLookAt(x, y, z, 0.0, 0.0, 500000.0, 0.0, 1.0, 0.0); //cam pos, eye, up
glRotatef(rotationY, 0.0, -1.0, 0.0);
glRotatef(rotationX, -1.0, 0.0, 0.0);
//draw the terrain next****************