PDA

View Full Version : GL_INVALID_OPERATION after glEnd()



Dee.cz
11-14-2007, 03:07 PM
Hello,
this renders 1 triangle, but glEnd() generates GL_INVALID_OPERATION. Any idea what's invalid?

#include <GL/glut.h>
#include <cstdio>

void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex3f(0,1,0);
glVertex3f(1,0,0);
glVertex3f(-1,-1,0);
printf("glGetError() before glEnd() returned 0x%x\n",glGetError());
glEnd();
printf("glGetError() after glEnd() returned 0x%x\n",glGetError());
glutSwapBuffers();
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(640,480);
glutCreateWindow("test");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

Output is

glGetError() before glEnd() returned 0x0
glGetError() after glEnd() returned 0x502

GeForce 6150, haven't tried Radeon yet.

sqrt[-1]
11-14-2007, 05:03 PM
It is invalid to call glGetError() between a glBegin and glEnd.

FYI you can use something like GLIntercept to catch OpenGL errors. (breakpoint on error etc) http://www.opengl.org/sdk/tools/GLIntercept/

Dee.cz
11-15-2007, 10:13 AM
Thanks!
Good drivers, good! I wasn't getting this error one year ago.