Sign in to follow this  

glDrawElements crash! (params are correct)

This topic is 4583 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This bug is one of the wierdest I've seen, and I can't fix it. I started using the Cal3D lib for animations. After managing to run their example just fine, I tried using it in my existing engine, by simply copying the files and calling the exact same functions. CRASH. After debugging a bit, I found it crashing on this line: glDrawElements(GL_TRIANGLES, faceCount * 3, GL_UNSIGNED_SHORT, &meshFaces[0][0]); After hand-verifying the params are correct, I looked all over for what may cause it to crash. To make a very long story short, I found out that if I glLoadIdentity the GL_PROJECTION before my frustum culling initialization (?!), it suddenly works! To clear a few things: I provide the project identity matrix to the frustum init, but right after that restore it. I do not mess with the model-view. My frustum culling is in NO WAY related to Cal3D's lib or with my rendering code written for Cal3D (of course it's related to other rendering code, but that code works just fine). In fact, it's taken straight from GameTutorials, with hardly any changes. The Cal3D rendering code does not include the frustum code and vice-versa. In fact, the frustum code doesn't export any variable! (just funcs) The only global variable in the frustum code is "modelview_frustum". Hardly a chance of colliding with anything. And just to emphasize this again: If I run the init with normal projection, glDrawElements crash, and if I run it with identity project, glDrawElements work just as it's meant to. No other change in the code is done!! Can someone please, please, help me through this voodoo? Thanks.

Share this post


Link to post
Share on other sites
Well, I finally managed to render that Cal3D model, and render myself as a complete idiot.
Just so you'll all learn from my mistake - somewhere in my code I used DrawArrays and forgot to disable one of my client-states, so glDrawElements tried to access an uninitialized pointer, for some texture coords or something..
The reason it didn't come up before was that the following DrawArray used that client-state as well...

Now please excuse me while I go read "C for dummies"...

Share this post


Link to post
Share on other sites

This topic is 4583 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this