Tracking down a native crash in glDrawArrays

I’m getting a native crash in glDrawArrays and was wondering if anyone had any cunning ways of tracking it down.

It only appears to happen when I mix both textured and non-textured geometry in one frame (sprites and wireframe drawing). Individually the two shaders work fine, but not when both are used.

All params to draw arrays look fine - a reasonable amount of vertices (2804 vertices taking 67296 bytes). Changing the order of drawing still crashes, and trying to bind fixed-function at the end of the frame still causes a crash.

All drawing is regular vertex arrays, no VBOs. No FBOs either. I suspect I’ve left some dangling pointer or something inside GL state, but can’t figure out what it could be. Any suggestions for what to look at?

Maybe, in the case were you have mixed textured/untextured geometry, you accidently leave texcoord arrays enabled when not specifying them, for the untextured geometry.

Hmm, possibly. I’m actually using ARBVertexProgram.glEnableVertexAttribArrayARB() rather than using the fixed function tex coord/etc. arrays, but I might still have something active…

Ah, I think I have it: http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=15603

glEnableVertexAttribArrayARB is global state, not per-active-program state, which is what I was thinking. Going to be awkward to fix without reworking the whole structure though. :S

That clearly explains the crashes. It’s quite an important fix too, so you’d have to rewrite the whole structure anyway.

The way “around this” is to use VAOs, which encapsulate these attributes in a bindable object.

Yeah, part of my problem was that I designed this stuff with VBOs and VAOs in mind, but I haven’t got around to doing anything fancier than regular vertex arrays. Still, it was an easy fix in the end.

How widespread are VAOs these days? I suspect that since they’re GL3.0 I probably can’t rely on them existing so I’ll still need a fallback path.

The extension is supported by DirectX 9 cards, which equals a Geforce 6000 series card. That was 7 generations ago.
Source: http://feedback.wildfiregames.com/report/opengl/feature/GL_ARB_vertex_array_object

FYI: VBOs are just like VAs, with regards to the array states being global.