I'm working on a very simple program that draws 2 planes. A ground plane and a back ground plane.
I'm attempting to draw both planes using these points ordered in X, Y, Z coordinates.
background plane
- point 1 100.000002 100.000002 100.000002
- point 2 -100.000002 100.000002 100.000002
- point 3 -50.000001 -23.000001 100.000002
- point 4 50.000001 -23.000001 100.000002
ground plane
- point 1 -50.000001 -23.000001 100.000002
- point 2 50.000001 -23.000001 100.000002
- point 3 0.352941 -0.352941 0.352941
- point 4 -0.352941 -0.352941 0.352941
My GL Setup:
- OpenGL lighting is off.
- I'm drawing with GL_QUAD in the order the points are listed.
- I have not assigned surface normals to the quads.
- Camera is centered at (0,0,0) with the Y+ as "up" and the Z axis as depth.
The ground plane renders perfectly (just a sheet of gray), but the background plane isn't rendering at all. So I have to ask:
- Should I turn on lighting and compute surface normals?
- Do I need to fiddle with the camera and/or view frustrum to see the back plane (does OpenGL "drop off" at a distance of Z = 100+)?
Any help is appreciated. I'm using libSDL with OpenGL.
My OpenGL initialization code looks like this:
if(SDL_Init(SDL_INIT_VIDEO) < 0) {
return false;
}
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
screenptr = SDL_SetVideoMode(swidth, sheight, sbpp, VIDEO_MODE_OPTIONS);
if( screenptr == NULL) {
return false;
}
glEnable(GL_TEXTURE_2D);
glClearColor(0,0,0,0);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//gluPerspective(45.0f, SCREEN_WIDTH/SCREEN_HEIGHT, 0.1f, 500.0f);
//gluPerspective( 45.0f, 1.0, 0.1f, 100.0f );
//glFrustum(-500.0f, 500.0f, -500.0f, 500.f, 0.1f, 500.f);
//glFrustum(-1.0, 1.0, -1.0, 1.0, 5, 400);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
if(glGetError() != GL_NO_ERROR) {
return false;
}
