PDA

View Full Version : how to handle GL_STACK_OVERFLOW?



07-26-2003, 09:46 PM
Dear sirs,
I get GL_STACK_OVERFLOW error when I pan oe zoom the window, I know that is there is more objects than OpenGL can handle. but how to clear this error, will you please help me? thank you

Diego_Jian

Some guy
07-27-2003, 02:32 AM
Originally posted by Diego_Jian:
I know that is there is more objects than OpenGL can handle.

No, its a stack overflow. Probably do your code has a glPushMatrix without any corresponding glPopMatrix.

Omaha
07-27-2003, 02:49 AM
In the program I'm developing on the side, I had to deal with this recently. Some of my code is very liberal with pushing the projection matrix stack, which is usually rather short (on my Geforce 3, height of 4 matrices.)

I made up for this by initializing a counter to the value of GL_MAX_PROJECTION_STACK_DEPTH-1 (since the active matrix is "on the stack" too) and subtracted 1 whenever I called a function that required pushing and added 1 to a max of GL_MAX_PROJECTIONSTACK_DEPTH-1 when I popped. If the value reached zero and I tried to push, I would retrieve the active matrix via glGetDoublev, and push it onto an std::stack designed to hold matrices. The value would then drop below zero. A pop attempt with a value less than zero indicated that I should pop the top matrix from that stack and then just shove it into OpenGL with glLoadMatrixd.

07-27-2003, 10:01 PM
yes, u r right! thank you!!


Originally posted by Some guy:
No, its a stack overflow. Probably do your code has a glPushMatrix without any corresponding glPopMatrix.