• Create Account

### #Actualmhagain

Posted 23 September 2012 - 10:24 AM

Your current matrix mode is GL_PROJECTION when you're drawing and GL only specifies a stack depth of 2 for that (individual implementations may provide more but it's not guaranteed). The amount of pushing and popping you're doing is just overflowing the matrix stack.

You probably also don't want to be calling glScalef and glTranslatef on the projection matrix; these are more commonly used on modelview (the fact that the projection matrix stack is only specified as 2 deep is a pretty good hint that it's not intended to be used this way).

A more normal 2D drawing routine would look like:
glMatrixMode (GL_PROJECTION);
glOrtho (...);

glMatrixMode (GL_MODELVIEW);
// draw objects with pushing/popping per-object if required