I’ve stumbled on an issue in OpenGL that I can’t explain, unless I somehow misunderstood how glPushMatrix() / glPopMatrix() work.
Shouldn’t the two pieces of code below have exactly the same effect?
glPushMatrix();
glVertex3f(0,0,0);
glTranslatef(c->e->coords[0], c->e->coords[1], c->e->coords[2]);
glPopMatrix();
vs
glVertex3f(c->e->coords[0], c->e->coords[1], c->e->coords[2]);
In my application, only when I use the second one do I see anything. I tried with both pieces of code in the exact same place in the code, changing nothing else, and the one with push/pop matrix doesn’t draw anything on screen.
You can’t call
glPushMatrix()/PopMatrix()inside aglBegin()/glEnd()block.glBegin():Recommendation: Use vertex arrays or vertex buffer objects instead of classic immediate-mode
glBegin()/glEnd()blocks.