Reputation: 13
I'm having some problems translating an object I'm drawing. This is the entirety of my display function. I can't seem to find anything I'm doing wrong.
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, 720, 480, 0, -1.0, 1.0);
glTranslatef(-0.5f,0.0f,0.0f);
//drawing object here
glPopMatrix();
glutSwapBuffers();
Upvotes: 0
Views: 189
Reputation: 110658
You need to start modifying the modelview matrix stack after you've done glOrtho
:
// ...
glOrtho(0, 720, 480, 0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glTranslatef(-0.5f,0.0f,0.0f);
// ...
But now your glPushMatrix
and glPopMatrix
are modifying different stacks, so the glPopMatrix
will result in an error. You shouldn't need them for such a simple example anyway.
Upvotes: 2