First of all, sorry for my bad english, but I’m not an native-speaker.
I’m interessted in learning OpenGL, but have some problems with it.
Here is a small code from
glClearColor (0.0, 0.0, 0.0, 0.0);
glColor3f (1.0, 1.0, 1.0);
glLoadIdentity (); /* clear the matrix /
/ viewing transformation /
gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glScalef (1.0, 2.0, 1.0); / modeling transformation */
void reshape (int w, int h)
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
int main(int argc, char** argv)
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
There is a function called ‘init’. For what kind of stuff is it? Why can’t we write the first lines of ‘int main’ in these function?
The function ‘reshape’ is for dealing with windows, which changed their height and width. When a window is changing his height/width, will only ‘reshape’ execute or also ‘display’?
The second big problem is, understanding OpenGL’s Matrixmode GL_MODELVIEW and GL_PROJECTION.
With GL_MODELVIEW, I’m able to paint my GL_QUADS, GL_LINES etc.
GL_PROJECTION will be used for perspective.
In the example I gave, ‘Display’, is no matrixmode are given. I think, GL_MODELVIEW is working to set my objects in the coordinatesystem up.
Why GL_PROJECTION is used in ‘Reshape’?
I’m not able to understand. Sometimes, MODELVIEW stands before PROJECTION, sometimes the other way.
Can you help me please?