I'm very new to opengl, and I might not fully understand the openGL matrix projection stack thing.

So, I have about 300 'objects' in my scene, each with their own position/rotation, and I want to draw them all (ignore culling and overdrawing for now). Would it be efficient enough to:

for each object {
    glMultMatrix(object pose);

    // do object drawing


or is there a better way to draw each object?

  • 2
    \$\begingroup\$ glPushMatrix()/glPopMatrix are legacy. Modern graphics programming uses programmable pipeline with all it's features. Check this: gamedev.stackexchange.com/questions/16423/… In your case you can use instancing to render many(MANY) objects \$\endgroup\$
    – Raxvan
    Apr 8, 2015 at 11:00

2 Answers 2


Generally speaking, using old OpenGL API is not efficient.

In ye olden days of OpenGL 1.0 this pattern was necessary. The model view matrix contains the model and the view matrix. You have the view matrix on the camera and the model matrix on the model. You set the view matrix onto the model view matrix and then push/pop the model matrix on top of it for each object. This was the most efficient way to do it.

But since OpenGL 3.0 the these matrices don't exist anymore and you need to maintain your own state and submit them as uniforms to the shader. As a result this question basically is obsolete. The most efficient way is to compute the matrices in the CPU as you need them. For example if you only need a projection-view-model, it makes sense to compute the PVM matrix on the CPU instead in the vertex shader over and over again.


generally it's acceptable but not best. If objects share same material and animation skeleton, make them into one batch and call glDrawArray once, though it's advanced usage if you are new to opengl, and it need more code work to achieve. you can read this and this for reference.

Another simpler way is reduce the glPush/Pop Call by grouping objects share same transform. Push /Pop matrix once and draw the group.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .