Drawing problem. (Depth problem, maybe..)

Hey, for some reason when I set up a window with OpenGL/GLUT and I try to draw something which doesn’t fit in the screen, it doesn’t draw it. I have to draw a polygon or a primitive that fits the screen. Can anybody please tell me why the below code does not draw a white quad from -100 to +100 (x and z).

#include <math.h>
#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glut.h>

void init(void)
{
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);

}

void keys(int key, int x, int y)
{
switch (key)
{
case GLUT_KEY_UP:
//move(1);
break;
case GLUT_KEY_DOWN:
//move(-1);
break;

}

}

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// color white
glColor3f(1.0, 1.0, 1.0);

//draw floor
glBegin(GL_QUADS);
     glVertex3f(-10.0, 0.0, -10.0);
     glVertex3f(-10.0, 0.0, 10.0);
     glVertex3f(10.0, 0.0, 10.0);
     glVertex3f(10.0, 0.0, -10.0);
glEnd();

glutSwapBuffers();

}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowPosition(100, 100);
glutInitWindowSize(300, 300);
glutCreateWindow(“Camera movement”);

init();

glutDisplayFunc(display);
glutSpecialFunc(keys);
glutIdleFunc(display);

glutMainLoop();

return 0;

}

Hi !

before you can render anything in the OpenGL window you must setup the projection and modelview matrix, you must also set the viewport, take a look at any example (make a search on google if you don’t have one at hand) to see how it’s done. Glut itself comes with some nice examples also.

Mikael

Hey, thanks for the reply.

If I make something smaller, eg, a cube or a smaller polygon which fits on teh screen, its draws it. Why does it not draw it otherwise?

I didn’t think the others were neccesary, I’ll have a look and get a bit more reading done. Thanks