Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (767)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (854)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [LWJGL] An EXCEPTION_ACCESS_VIOLATION on glDrawElements that really has me.  (Read 1098 times)
0 Members and 1 Guest are viewing this topic.
Offline quew8

JGO Knight


Medals: 53



« Posted 2014-05-31 18:01:57 »

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.

Quote
d | 1215971556 | glEnableVertexAttribArray_P() {index = 0}
d | 1215971595 | glEnableVertexAttribArray_P() {index = 1}
d | 1215971596 | glEnableVertexAttribArray_P() {index = 2}
d | 1215971656 | glAttachShader_P() {program = 1, shader = 2}
d | 1215971659 | glAttachShader_P() {program = 1, shader = 3}
d | 1215971660 | glBindAttribLocation_P() {program = 1, index = 0, name = position}
d | 1215971662 | glBindAttribLocation_P() {program = 1, index = 1, name = normal}
d | 1215971663 | glBindAttribLocation_P() {program = 1, index = 2, name = texCoords}
d | 1215972507 | glBindBuffer_P() {target = GL_ARRAY_BUFFER, buffer = 1}
d | 1215972514 | glBufferData_P() {target = GL_ARRAY_BUFFER, data = BB{pos = 0, lim = 128, cap = 128}[0, 0, -96, -64, 0, 0, -96, -64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -128, -65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -96, 64, 0, 0, -96, -64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -128, -65, 0, 0, -128, 63, 0, 0, 0, 0, 0, 0, -96, 64, 0, 0, -96, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -128, -65, 0, 0, -128, 63, 0, 0, -128, 63, 0, 0, -96, -64, 0, 0, -96, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -128, -65, 0, 0, 0, 0, 0, 0, -128, 63], usage = GL_STATIC_DRAW}
d | 1215972517 | glBindBuffer_P() {target = GL_ARRAY_BUFFER, buffer = 0}
d | 1215972658 | glBindBuffer_P() {target = GL_ELEMENT_ARRAY_BUFFER, buffer = 2}
d | 1215972660 | glBufferData_P() {target = GL_ELEMENT_ARRAY_BUFFER, data = BB{pos = 0, lim = 24, cap = 24}[0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0], usage = GL_STATIC_DRAW}
d | 1215972679 | glBindBuffer_P() {target = GL_ELEMENT_ARRAY_BUFFER, buffer = 0}
d | 1215972913 | glEnable_P() {cap = GL_DEPTH_TEST}
d | 1215972915 | glEnable_P() {cap = GL_STENCIL_TEST}
d | 1215973067 | glBindBuffer_P() {target = GL_ARRAY_BUFFER, buffer = 1}
d | 1215973068 | glBindBuffer_P() {target = GL_ELEMENT_ARRAY_BUFFER, buffer = 2}
d | 1215973070 | glEnableVertexAttribArray_P() {index = 1}
d | 1215973071 | glEnableVertexAttribArray_P() {index = 2}
d | 1215973074 | glEnableVertexAttribArray_P() {index = 3}
d | 1215973076 | glVertexAttribPointer_P() {index = 0, size = 3, type = GL_FLOAT, normalized = false, stride = 32, bufferOffset = 0}
d | 1215973078 | glVertexAttribPointer_P() {index = 1, size = 3, type = GL_FLOAT, normalized = false, stride = 32, bufferOffset = 12}
d | 1215973080 | glVertexAttribPointer_P() {index = 2, size = 2, type = GL_FLOAT, normalized = false, stride = 32, bufferOffset = 24}
d | 1215973083 | glDrawElements_P() {mode = GL_TRIANGLES, count = 6, type = GL_UNSIGNED_INT, bufferOffset = 0}

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.
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1255 views)
2018-06-10 19:43:48

EgonOlsen (1124 views)
2018-06-10 19:43:44

EgonOlsen (862 views)
2018-06-10 19:43:20

DesertCoockie (1270 views)
2018-05-13 18:23:11

nelsongames (1104 views)
2018-04-24 18:15:36

nelsongames (1334 views)
2018-04-24 18:14:32

ivj94 (2073 views)
2018-03-24 14:47:39

ivj94 (1226 views)
2018-03-24 14:46:31

ivj94 (2169 views)
2018-03-24 14:43:53

Solater (792 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!