glad icon indicating copy to clipboard operation
glad copied to clipboard

Debug OpenGL generator calls glGetError after glBegin

Open stgatilov opened this issue 7 months ago • 1 comments

Hello!

I have started a tiny toy project, where I use old OpenGL for simplicity. I load OpenGL functions using GLAD, which is integrated via conan2 with default settings. And I noticed that I get spam of ERROR 1282 in glEnd in the console every time I call glBegin + glEnd, even if there is nothing in between.

The spam happens only in Debug build but not in Release. Because the conan package specifies GLAD_GENERATOR = c-debug instead of c in Debug build (in this line). And in this case GLAD code calls _post_call_callback_default_gl after glBegin, which calls glad_glGetError. However, it turns out that calling glGetError inside glBegin/glEnd scope is not allowed =)

No idea if this issue is worth fixing though, given that immediate mode rendering is quite dead today. I guess I can workaround the issue by forcing conan to always use Release build of GLAD.

P.S. Thank you very much for the loader! I used it in the past, and was very glad with how it worked =)

stgatilov avatar Aug 22 '25 20:08 stgatilov

Oof, that is quite a tricky issue I didn't consider.

  • I think we could track each pair of invocations from glBegin to glEnd and not call that in the error hook.
  • Looking at the man page, it seems like GL_INVALID_OPERATION is only generated when called between glBegin and glEnd ... so we could also just ignore that error (obviously this will mean additional gl* calls, but the debug mode isn't supposed to be very efficient anyways)

Dav1dde avatar Aug 24 '25 08:08 Dav1dde