#include #include #include #include #include #define WINDSIZEX 100 #define WINDSIZEY 100 GLint maxDepth, maxClientDepth, currentDepth; void init(void) { glGetIntegerv(GL_ATTRIB_STACK_DEPTH, ¤tDepth); printf("current stack depth %d\n", currentDepth); assert(currentDepth == 0); glGetIntegerv(GL_CLIENT_ATTRIB_STACK_DEPTH, ¤tDepth); assert(currentDepth == 0); glGetIntegerv(GL_MAX_ATTRIB_STACK_DEPTH, &maxDepth); glGetIntegerv(GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, &maxClientDepth); printf("max stack depth %d\n", maxDepth); printf("max client stack depth %d\n", maxClientDepth); } void test() { int i; while (GL_NO_ERROR != glGetError()); for (i = 0; i < maxClientDepth; i += 1) { // printf("%d ", i); glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); if (GL_STACK_OVERFLOW == glGetError()) { exit(1); } } for (i = maxClientDepth; i > 0; i -= 1) { glPopClientAttrib(); } glPopClientAttrib(); if (GL_STACK_UNDERFLOW != glGetError()) { printf("PopClientAttrib: Did not Set GL_STACK_UNDERFLOW\n"); exit(-1); } } void display(void) { glViewport(0, 0, WINDSIZEX, WINDSIZEY); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, WINDSIZEX, 0, WINDSIZEY); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); test(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(WINDSIZEX, WINDSIZEY); glutInitWindowPosition(100, 100); glutCreateWindow(argv[0]); init(); glutDisplayFunc(display); glutMainLoop(); return 0; }