Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I have a simple 2D scene and I want to move the objects inside the scene on the X and Y axis, should I send OpenGL the original vertex coordinates with each move and apply a ModelView matrix transform, or should I simply send the updated coordinates?

Since the scene is simple and there are really not that many vertices, I'm not using vertex buffers.

share|improve this question
up vote 2 down vote accepted

The proper way to do it is to use the ModelView matrix to move your object. The object's vertices are defined in the local space of the object, and it's generally good practice not to disturb the data.

This scales well to complex 3D objects and animation because the joint transforms and ModelView matrix operations can be done much faster in a shader than in software. Even if your scene is simple, it's good to adhere to the proper methods.

UPDATE: It's still ok to modify the ModelView matrix outside of the shader. For each object, this only means that we'll do 2 or 3 matrix-matrix multiplications per-frame outside of a shader, and then N matrix-vector multiplications inside the shader, where N is the number of vertices in the object.

share|improve this answer
Makes sense. So the best way to do this would be to calculate the matrix transform inside the shader, and only pass attributes containing the X and Y values to translate? – rid Apr 9 '12 at 5:05
If you really wanted to get all the performance you could out of a shader, you could do that I guess, but it kind of over-complicates things. I've updated my answer to explain why it's still ok to modify the ModelView matrix outside of a shader. – ktodisco Apr 9 '12 at 5:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.