Ok, so I want to try out a little opengl programming. So I go and start reading the OpenGL Programming Guide v1.0. I follow the instructions, and I think I understand things, but then those things don’t work! In specific, transformations don’t do what they do in everyone else’s sourcecode, stuff gets culled where I’m not expecting it, and glFrustum has no effect whatsoever! If anyone can help me, I’d be most appreciative.
Here’s some code:
glViewport(0, 0, (GLsizei) x, (GLsizei y);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-100, 100, -100, 100, 0.001, 10000.0);
glMatrixMode(GL_MODELVIEW);
The above gets run once per window resize and at the start of the program. The numbers I pass to glFrustum do not affect the scene rendered at all! What am I doing wrong?
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glRotatef(cam_rot_z, 0.0, 0.0, 1.0);
glRotatef(360 - cam_rot_y, 0.0, 1.0, 0.0);
glRotatef(cam_rot_x, 1.0, 0.0, 0.0);
glTranslatef(-cam_x, -cam_y, -cam_z);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
That is supposed to set up the viewing system to point in the right direction. cam_x through cam_z are the coordinates of the viewer, and cam_rot_x through cam_rot_z are the number of degrees (I think?) around each axis that the viewer is rotated. Depending on what you read, there are a million ways to do the above, but I chose this method so I would understand it. But ofcourse it doesn’t work. The object I’m viewing rotates and moves as if all those negative signs weren’t there at all. I hope someone can help me with all this.
Phil