Thanks Mikael.
One more question:
Is that the best way since there is a limit for the Matrix Stack concerning Push and Pop(32)?
How can i make one Object being moved
by translation and rotation when it is selected and the others not without defining every object with its own PushMatrix and Popmatrix??
Like this:
Pushmatrix()
obj1
obj2
obj3
.
.
.
Popmatrix

Now i have selected Obj3
What to do to rotate just Obj3 now??

For each object you want to transform without affecting other objects, draw the object inside yet anoter glPush/PopMatirx pair, and make the object specific transformation inside that pair.

Sorry, didn’t see you wanted to do it without push/pop. Well, is there a reason you DON’T want to use them?

You can of course keep on transforming each object, without pushing them, and when you want to go back one step in the transformation (i.e. pop the stack), you can load the identity matrix, and redo all matrix operations but the last one.

Yes, there is a limit on the modelview stack. The depth is implementation depdenent, but you are guaranteed to have at least 32 matrices deep stack. That means you can call glPushMatrix at least 32 times, with out popping the stack. That that should be more than enough for any not too advanced application.

I don’t think the limit of 32 is a problem, since you would have to push 32 times in a row and not pop to go over the 32.
If you push then pop each object you are still back at zero.

example

glPushMartix() // Push matrix by 1
draw_object1()
glPopMatrix() // Pop matrix subtract matrix by 1

glPushMartix() // Push matrix by 1
draw_object2()
glPopMatrix() // Pop matrix subtract matrix by 1

If you do the math your matrix is back at zero.

A little more advanced:

glPushMartix() // Push matrix by 1
glTranslate(…) Move robot
glRotate(…) Rotate robot
draw_robot_body()
glPushMartix() // Push matrix by 1
glRotate() // move robot arm
draw_robot_arm()
glPopMatrix() // Pop matrix subtract matrix by 1

glPushMartix() // Push matrix by 1
glRotate(…) // rotate robot legs
draw_robot_legs()
glPopMatrix() // Pop matrix subtract matrix by 1

glPopMatrix() // Pop matrix subtract matrix by 1

same results matrix is back at zero.

Originally posted by Stef:
[b]Thanks Mikael.
One more question:
Is that the best way since there is a limit for the Matrix Stack concerning Push and Pop(32)?
How can i make one Object being moved
by translation and rotation when it is selected and the others not without defining every object with its own PushMatrix and Popmatrix??
Like this:
Pushmatrix()
obj1
obj2
obj3
.
.
.
Popmatrix

Now i have selected Obj3
What to do to rotate just Obj3 now??[/b]