PDA

View Full Version : How do I reset to original state?



jacktca
11-07-2011, 06:48 PM
I have a 3D model which I load using glTextImage3d. I do lots of manipulation commands. At some point I want to reset to the original (default) position. How do I do this?

I tried glLoadIdentity but it makes the screen go blank.

I tried glLoadMatrix with matrices of 16 1's or 2's but that did not work.

I know about push and pop but I don't want to save the state. I just want a command that will reset the opengl to default settings.

V-man
11-08-2011, 05:18 AM
The default modelview matrix is the identity matrix. What exactly is your question?

What the heck is this

I tried glLoadMatrix with matrices of 16 1's or 2's but that did not work.

jacktca
11-08-2011, 11:46 AM
There are examples on the internet where someone loads 16 1's or 2's into a float array and passes it to glLoadMatrix. That does nothing for me.

My question is pretty clear. I have a 3D object. I move it around: roll, pitch, yaw, up/down, zoom in/out. I want to press reset and return it to its original location.

glLoadIdentity blanks the screen out.

Alfonse Reinheart
11-08-2011, 11:54 AM
There are examples on the internet where someone loads 16 1's or 2's into a float array and passes it to glLoadMatrix.

Where? I'd love to see that code.


I have a 3D object. I move it around: roll, pitch, yaw, up/down, zoom in/out. I want to press reset and return it to its original location.

Then reset it.

OpenGL should not be used to store the position and orientation of an object. It should not hold on to it for any length of time. The way you render a frame with OpenGL is generally as follows:

1: Set up transform to move object A to where you want it.
2: Render object A.
3: Set up transform to move object B to where you want it.
4: Render object B.
...

You should not have OpenGL's transformation matrices store the position of your object. You should store your rotations, translations, etc yourself, in your own data structures. And every frame, you apply these matrices to OpenGL, and then render your object.

So to reset your transforms, you simply set your internal data back to whatever the "original location" is.