I was just wondering why do we exactly call glTranste command if its possible just to increase objects x, y or z. And its even stated in this tutorial: http://nehe.gamedev.net/tutorial/particle_engine_using_triangle_strips/21001/ that its even faster to only use Vertex3f() instead of resetting the Modelview Matrix.

Anyways, maybe its just something particular in this tutorial why we do exactly that or something similar, but i would like to know more.

Recommended Answers

All 5 Replies

glTranslate translate the current view matrix, not just one object. So it can be used for different things

I cant believe i havent though about it, i guess its a LOT better to just translate everything when i want to move around the world then doing i to every object seperatly, but maybe theres more regarding my quostion.

The model-view matrix will always be applied to the vertices, so it makes no difference (speed-wise) whether the transformation is the identity matrix or whether it has any transformations accumulated in it (rotations and translations).

OpenGL is given a model-view matrix and a set of vertices, and it will apply the matrix to all the vertices to transform them to screen coordinates.

You could do this yourself, that is, you leave the model-view matrix to identity and then transform the set of vertices yourself before giving them to OpenGL. However, that will never be faster nor easier than letting OpenGL do it for you. Not only does it save you the coding (traversing the vertices and applying the transformation), but it is also much more efficient because the GPU is a processor that was designed to do this 4D matrix-vector multiplication very fast.

Of course, in the case of a particle system, you are rendering a small and simple thing (sprite) at many different places. You probably shouldn't change the model-view matrix for each particle in your particle system, because there is some overhead in changing the model-view matrix, and doing so for each particle might be too much. Because each particle is only translated, it might be just as easy to add the translation to the few vertices directly. But this just a special case, under most circumstances (when the ratio of vertices rendered per changes to the model-view matrix is a bit higher), you are better off using the model-view matrix for all vertex transformations.

@OP

Objects are generally specified in a Local Coordinate System. The ModelView Matrix transforms the objects into the World Coordinate System.
This link maybe helpful to you:

Link

Thanks for clearing this out for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.