Original Post
Hi, I am very new to OpenGL. Why does the following code show nothing (white background). I thing there should be a camera problem: #include #include #include using namespace std; #define KOORDINATENACHSE 1 void init(); void renderScene(); void reshapeWindow(int,int); int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE| GLUT_RGBA); glutInitWindowPosition(100,100); glutInitWindowSize(800,600); glutCreateWindow("OpenGL"); init(); glutDisplayFunc(renderScene); glutReshapeFunc(reshapeWindow); glutMainLoop(); return 0; } void init() { glClearColor(1.0F,1.0F,1.0F,1.0F); glEnable(GL_DEPTH_TEST); glShadeModel(GL_FLAT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(80,1.0,0.1,100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void renderScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(3,2,5,0,0,0,0,0,1); glNewList(KOORDINATENACHSE,GL_COMPILE_AND_EXECUTE); glBegin(GL_LINES); //X-Achse: rot glColor3f(1.0,0.0,0.0); glVertex3d(0.0,0.0,0.0); glVertex3d(10.0,0.0,0.0); //Y-Achsr: gruen glColor3f(0.0,1.0,0.0); glVertex3d(0.0,0.0,0.0); glVertex3d(0.0,10.0,0.0); //Z-Achse: blau glColor3f(0.0,0.0,1.0); glVertex3d(0.0,0.0,0.0); glVertex3d(0.0,0.0,10.0); glEnd(); glEndList(); glBegin(GL_QUADS); glColor3f(0.5,0.3,0.9); glVertex3d(-100,-100,0); glVertex3d(100,-100,0); glVertex3d(100,100,0); glVertex3d(-100,100,0); glEnd(); glFlush(); } void reshapeWindow(int w,int h) { if(h == 0) h = 1; float ratio = 1.0* w / h; // Reset the coordinate system before modifying glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Set the viewport to be the entire window glViewport(0, 0, w, h); cout<<"reshape"<<endl; }