Background
Before I get into the nitty gritty, I think I need to give a little background. I have written an API which among other things provides an interface to OpenGL and windowing utils for which I have backends for both Android and Desktop (through LWJGL) the purpose of which is obviously to use the same code on Android and Desktop. I also have my own rendering library which uses this OpenGL / windowing interface.
So this game I was originally writing on Android where it was working fine, but this error appeared when I ported it to Desktop. Now I have two other games on Desktop that use the same rendering library and OpenGL interface so it cannot be a fundamental problem with either of those things.
The Error
So here is a pastebin of the native stack trace http://pastebin.com/0fWKe8x7 but long story short it is, as per the thread title, an EXCEPTION_ACCESS_VIOLATION after calling glDrawElements(). My experience is you get this when the indices and pointers you have supplied point to data that doesn’t exist but I can’t see how that is the case. Also my system specs are all there if needed.
Rather than posting reams of code (and it would be a hell of a lot) I’m going to post a list of calls of OpenGL functions (not all of them, only the pertinent ones + a few more - if you think any others are pertinent then ask and I’ll post them too). Don’t worry, the contents of the buffers are below this in a more readable format.
Since the BufferData is given in bytes rather than ints or floats, I’ve converted them (and formatted a little) below and I wrote a whole new program to do that so there is no human error.
ARRAY_BUFFER id 1 as floats, divided into vertices and vertex components.
[-5.0 -5.0 0.0] | [0.0 0.0 -1.0] | [0.0 0.0]
[5.0 -5.0 0.0] | [0.0 0.0 -1.0] | [1.0 0.0]
[5.0 5.0 0.0] | [0.0 0.0 -1.0] | [1.0 1.0]
[-5.0 5.0 0.0] | [0.0 0.0 -1.0] | [0.0 1.0]
ELEMENT_ARRAY_BUFFER id 2 as ints.
0 1 2 0 2 3
As you might have guessed, it’s a square I’m trying to draw.
My intention for the interleaving of the vertex data: PPPNNNTT where P = position, N = normal, T = texture coord.
Finally
If you have any ideas at all, or if I have missed out some information then please don’t hesitate to post. I’ve been trying to solve this intermittently for many, many weeks. I’m so frustrated with this that today I found myself grinding my teeth and shouting at the computer when it took longer that a second to load up the JavaDoc which held the answer to another bug entirely.
Thank you for reading and thank you in advance for any help rendered.
Q8.