Geometry and Transformations (Basic understanding of OpenGL applications)

Started by
2 comments, last by kloffy 17 years, 1 month ago
I have recently run into a problem with a little program of mine. It's a pretty basic question about the way to handle geometry and transformations in an OpenGL application. As far as I can tell from various tutorials, the usual way to do this is something like this: glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Apply Transformations glBegin(/* Something */); // Draw Geometry glEnd(); However, this means all the transformations are applied during rendering. That means I run into a problem if I need to know the final coordinates in my program logic. For example, if I wanted to write a picking algorithm, I would have to apply the transformations beforehand and all the OpenGL transformations would become more or less useless, since I already know the absolute position of the object. I hope that was more or less understandable. What is the correct way to do this?
Advertisement
Opengl is ONLY for rendering.
If you want to apply in-game transformations to an object and know it's final location; then you need to calculate that yourself.
P.S.

since for our game-logic we end up doing a lot of these transforms ourselves.
the function GlMultMatrix() becomes our friend.
It allows us to take our in-game matrix math, and plug it directly into opengl.

(thus we avoid your point about duplicating work and having useless duplicated transforms)
I see, thanks for your input. That glMultMatrix() function seems to be what I'm looking for.

This topic is closed to new replies.

Advertisement