More greenhorn questions

During development i like to have a clean plate to start with.
Currently having success with this code:

		glClearColor(0x0, 0, 0, 0);

Seems little overkill, especially glLoadIdentity();
Like to hear some comments, but please no RTFM quotations.

…who is on first ? or does the sequence matter?

(glLoadIdentity();) whatever,,,


(glLoadIdentity();) whatever,,,
**glFlush(); **

I’m not sure what you want to comment on. My most obvious comment would be that you didn’t set the glClearDepth value. But this could go on and on and on; OpenGL 1.1 has a lot of context state. And while it’s a good thought to try to start each frame from a known state, there’s just so much that at some point, you just have to pick the state you care about within the context where you care about it.

Do you care about the state of the various matrices? Then set them. Do you care about the viewport state? Good; set it to a known value. Are you using the scissor box? If so, set the box’s state whenever you turn on scissor testing. Are you using blending? Then set the blend mode whenever you enable blending. Etc.


How exactly am I supposed to answer your question? The answer is basically “here’s what these functions do,” because if you know what they do, then the “sequence” is obvious.

Give a man a fish, and you feed him for a day; teach a man to fish, and maybe he doesn’t post so many messages on your forum.

Consider this hypothetical code:

j = 2 + 5;
c = func(a, b);

Is that the correct “sequence” of operations? Would putting j = 2 + 5 after the call to func be more correct or less correct?

You know the answer to that, because you know that j = 2 + 5 cannot affect the values of a or b, nor will it likely affect the operation of func. Therefore, you know that it doesn’t matter.

glFlush has nothing to do with the matrix stack or the current matrix, which you would know if you read the manual. glPopMatrix affects the current matrix and the matrix stack, which again you should already understand. So if you understood what is in the manual, then you should see that the order of these two functions is as irrelevant as the the order of j = 2 + 5 relative to c = func(a, b).

In short: reading the manual is how you learn whether there is any relationship between functions.