Logic behind gLoadIdentity

Dear all,

All these day I use to specify glLoadIdentity (for Modelview matrix) inside the callback function of glutReshape. Now I found a billboarding example whereby glLoadIdentity is specified in the display call back func.
When I removed this glLoadIdentity and put in the Reshape callback func, the entire scene is moving away .

What is the logic behind glLoadIdentity. Where exactly is place for glLoadIdentity part of glMatrixMode(G_MODELVIEW).

With regards

I would say that you can do what you want, even no use it at all (using only glPushMatrix /glPopMatrix). But stay consistent with ONE approach, moving it around will screw up everything.

glLoadIdentity reset’s the matrix, so that you start at a know state. You have two matrix’s, the Projection and the Modelview. That is why it is called twice, once to reset the Projection and then to reset the Modelview.

There is a reason a pice of code is place at a said point, removing it changes the code
thus changes how the program functions.

The reshape is only called when the sceen size has changed.

In the case of glLoadIdentity, when you removed it from the display routine, it was not be called each time the display routine was called. So the Matrix was not reset and the changes made in the last call was not cleared but added to. That is why your scene was moving away.