Public Group

# world coordinate/local coordinate

This topic is 5268 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hello all, I'm new to this world of OpenGL and would like to understand the difference between local coordinate system & world coordinate system. Theoretically, i could understand the terms but am not able to implement an example by a tranformation of a cube. appreciate your inputs (Especially in reference to glMatrixMode (GL_MODELVIEW) ) just showing the render code in a way I could understand what happens when ~ boyd

##### Share on other sites
I got myself a result::

whatever transformations that happens inside the top glPushMatrix() & corresponding glPopMatrix () corresponds to the local coordinate system of the object where itz being intially transformed;

once the flow control comes out of corresponding glPopMatrix(), tranformations applied are done in world coordinate system.

I hope my conclusion is correct ? but still am not sure how coordinate systems (local to world) corresponds to GL_MODELVIEW ??

~boyd

##### Share on other sites
Basically it's just a matter of how you store the vertices of your cube. You may either store them in local or world coordinates. In local coordinates a vertex might look like (1.0; 0.0; 1.0) whereas in world coordinates it might be (312.0; 12.0; -13.0). To get the local coordinate cube to be displayed at the same spot as the world coordinate cube you would call glTranslatef(311.0, 12.0, -14.0); and the coordinates would be transformed to the correct position.

Local coordinates are usually better since you can easily apply a rotation about the center of the cube and the center of the world. With world coordinates you need to do some tricks before you can rotate around the center of the cube.

Hope that clarifies things a bit.

Edit: What goes on inside between glPushMatrix() and glPopMatrix() does not necessarily have anything to do with local or world coordinates. The transformations that take place between these calls will not have any effect after glPopMatrix(), so these calls are useful if you want to make unique transformations to a single object. Actually they are useful for a lot of stuff, but that's one perhaps one of the most common things they're used for.

glMatrixMode(GL_MODELVIEW) declares that you want to manipulate the modelview matrix which means that you are manipulating the positions of the vertices of your cube. Other matrix modes might transform texture coordinates or color values for example. So GL_MODELVIEW is not really related to local or world coordinates in a way that makes any difference.

##### Share on other sites
Hi!

Have you read the oh-so-good articles about OpenGL programming over at NeHe? That would be the first place to visit ifo you want to learn all the basics and a lot of not so basic. It's probably the most popular OpenGL tuts on the net...

Happy coding!

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634066
• Total Posts
3015317
×