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;
}