Reputation: 29
I am working on a small game which uses OpenGL.
I was getting a gl_stack_underflow error. I have gone through the code, and there is one glPushMatrix for each glPopMatrix. Any ideas what else could be causing this error?
Upvotes: 0
Views: 341
Reputation: 162317
Did you maybe do a
glMatrixMode(GL_MODELVIEW);
/* ... */
glPushMatrix();
"balanced" by a
glMatrixMode(GL_PROJECTION);
/* ... */
glPopMatrix();
It matters which matrix is active at the time of push/pop operation.
Anyway, you shouldn't use the OpenGL built-in matrix operations at all. Use something like GLM, Eigen or linmath.h to build the matrices as part of your programs data structures and just load the matrices you require with glLoadMatrix
or, when you finally go for shaders, glUniform
.
No, OpenGL built-in matrix operations are not GPU accelerated, so there's no benefit at all in using them.
Upvotes: 2