PDA

View Full Version : invalid operation after the glbegin



kamimail
11-10-2009, 05:26 AM
i have the following code to render the scene to a win32 dibsection:
e = glGetError();// no error

glBegin(GL_LINE_LOOP);

e = glGetError();// error code 1282

assert(e ==0);

double xmin,xmax,ymin,ymax;

GetGeoExtent( xmin,xmax,ymin,ymax);

glVertex3f(xmin,ymax,0);

glVertex3f(xmin,ymin,0);

glVertex3f(xmax,ymin,0);

glVertex3f(xmax,ymax,0);

glEnd();
Here is a debug-log (GLintercept) of the interesting rendering from above:
wglChoosePixelFormat(0xea012920,0x12f5b0)=20
wglSetPixelFormat(0xea012920,20,0x12f5b0)=true
wglCreateContext(0xea012920)
----->wglGetPixelFormat(0xea012920)=20
----->wglDescribePixelFormat(0xea012920,20,40,0x12f410)= 54 =0x10000
wglMakeCurrent(0xea012920,0x10000)
----->wglGetPixelFormat(0xea012920)=20 =true
glShadeModel(GL_SMOOTH)
glGetError()=GL_NO_ERROR
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,0x12f3fc)
glLightfv(GL_LIGHT1,GL_AMBIENT,0x12f3fc)
glGetError()=GL_NO_ERROR
glLightfv(GL_LIGHT1,GL_DIFFUSE,0x12f3e4)
glGetError()=GL_NO_ERROR
glLightfv(GL_LIGHT1,GL_POSITION,0x12f3d0)
glGetError()=GL_NO_ERROR
glGetError()=GL_NO_ERROR
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT1)
glGetError()=GL_NO_ERROR
glEnable(GL_DEPTH_TEST)
glGetError()=GL_NO_ERROR
glGetError()=GL_NO_ERROR
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(-28058.824219,28058.824219,-9000.000000,9000.000000,0.000000,786432.000000)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glMultMatrixf([1.000000,0.000000,0.000000,0.000000,0.000000,1.000 000,0.000000,0.000000,0.000000,0.000000,1.000000,0 .000000,0.000000,0.000000,0.000000,1.000000])
glTranslated(-1035000.000000,-315000.000000,-393216.000000)
glGetError()=GL_NO_ERROR
glGenTextures(1,0x251fa50)
glGetError()=GL_NO_ERROR
glBindTexture(GL_TEXTURE_2D,1)
glTexImage2D(GL_TEXTURE_2D,0,0x0003,256,128,0,GL_R GBA,GL_UNSIGNED_BYTE,0x2551008)
glGetError()=GL_NO_ERROR
glBindTexture(GL_TEXTURE_2D,0)
glGetError()=GL_NO_ERROR
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,0x12f 290)
glMaterialfv(GL_FRONT,GL_SPECULAR,0x12f278)
glMaterialfv(GL_FRONT,GL_SHININESS,0x12f268)
glGetError()=GL_NO_ERROR
glGetError()=GL_NO_ERROR
glBegin(GL_LINE_LOOP)
glGetError()=GL_INVALID_OPERATION

and there is no error return after glbegin in some app that come from nehe project . i dont know why this happened ,which case the glbegin will generate this error? thanks!

DindinX
11-10-2009, 06:18 AM
Yes, it is an invalid operation to call glGetError() between glBegin() and glEnd()

kamimail
11-10-2009, 07:33 PM
thanks