If "glPushMatrix()" is the command I am searching for the quadrat should be shown in the centre of my screen because of the translation to x=0, y=0 and z=0 !?
But there is no difference between using "glPushMatrix()" and not using it.

What I did not understand ?

nexusone

07-04-2004, 04:15 AM

I maybe did not understand you question fully.

There are many factors that effect where an object is drawn on the screen, from the projection setting to the matrix calls like glTranslate.

You may have to adjust your projection settings or view port settings to get what you want.
Post your code and will take a look.

glTranslate(0,0,0) has no effect since it has zero translation.

glPush/Pop does not change the matrix or reset it, it save's and restores it to the state before it was used. It will not make an object center on the screen if you do not have to other settings correct.

mObjects.map2D() #a function only filled with translations and objects
mObjects.menu() #a function only filled with translations and objects, too

The created objects are all in the bottom of the screen and somewhere there is my translated point. Of course I could add all my translations together to "go back" to the point at the beginning of the function but this has to be very hard because there are many translations which syntax I wrote with help of a complex loop. So the simplest way to create an indepentend object is to "go back" to the translation point at the beginning of my draw-function.

nexusone

07-04-2004, 06:18 AM

Yes, the best way to have a indepdent object is to start from a begining.

example draw a group of objects

Lets say we have set 0,0,0 as the center of the screen in the projection matrix.

Now when use glTranslate it only effects the current object, the Push/pop matrix restores the matrix back each time.

Also with Push/Pop matrix you can stack them.

Lets say you have a moon orbiting around a planet, the moon is drawn relative to the planet.

//Draw planet with moon

glPushMatrix();
glTranslate(....); // location of planet
drawPlanet();
glPushMatrix() // Works with multiple moons too
glTranslate(...); // location of moon relative to planet.
drawMoon();
glPopMatrix();
glPushMatrix();Also would suggest you look at some of my examples on my website, should give you some ideas.