Im currently learning how to use VBO’s and have come across an error I just can’t seem to fix.
Im making a simple program for making models, so Im using LWJGL with AWT.
This is the error:
Java™ Platform SE binary has stopped working (In a little Window’s window)
Viewing the problem details gives me this
Problem Event Name: APPCRASH
Application Name: javaw.exe
Application Version: 7.0.510.13
Application Timestamp: 52b25e38
Fault Module Name: StackHash_b4ee
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 00000000
Exception Code: c0000005
Exception Offset: 000000000615ff3d
OS Version: 6.1.7601.2.1.0.256.1
Locale ID: 4105
Additional Information 1: b4ee
Additional Information 2: b4ee5de6a2322745523997a782b35692
Additional Information 3: 277e
Additional Information 4: 277e19c30fbd5f6bb531ec9e027c37c3
Looking up error code c0000005 tells me its an “Access Permissions” issue
By trial and error I found the crash happening when I drew my VBO’s
[spoiler]
public static void drawQuad(int handles[]) {
for(int i =0;i < handles.length; i ++){
// System.out.println("Drawing handle : " + handles[i]);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, handles[i]);
glVertexPointer(3, GL_FLOAT, /* stride * */(3 * 2) << 2, /* offset * */
0 << 2); // float at index 0
glColorPointer(3, GL_FLOAT, /* stride * */(3 * 2) << 2, /* offset * */
(3 * 1) << 2); // float at index 3
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_TRIANGLES, 0, 3 /* elements */); //Commenting this out stops the crash?????
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
System.out.println("Finsihed rendering handle : " +(handles[i]));
}
}
[/spoiler]
Because it may be relevant how I create my VBO’s
[spoiler]
public static int[] createQuad(Vector3f vec1, Vector3f vec2, Vector3f vec3,
Vector3f vec4, Vector3f col) {
int[] handles = new int[2];
FloatBuffer triOne = BufferUtils.createFloatBuffer(6 * 3);
triOne.put(vec1.x).put(vec1.y).put(vec1.z); // v
triOne.put(col.x).put(col.y).put(col.z); // c
triOne.put(vec2.x).put(vec2.y).put(vec2.z); // v
triOne.put(col.x).put(col.y).put(col.z); // c
triOne.put(vec4.x).put(vec4.y).put(vec4.z); // v
triOne.put(col.x).put(col.y).put(col.z); // c
int handle1 = GL15.glGenBuffers(); // Create an ID for a buffered object
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, handle1); //Bind any incoming info to this buffer id
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, triOne, GL15.GL_STATIC_DRAW); //Attach the float buffer
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); // Unbind the object
handles[0] = handle1;
FloatBuffer triTwo = BufferUtils.createFloatBuffer(6 * 3);
triTwo.put(vec1.x).put(vec1.y).put(vec1.z); // v
triTwo.put(col.x).put(col.y).put(col.z); // c
triTwo.put(vec3.x).put(vec3.y).put(vec3.z); // v
triTwo.put(col.x).put(col.y).put(col.z); // c
triTwo.put(vec4.x).put(vec4.y).put(vec4.z); // v
triTwo.put(col.x).put(col.y).put(col.z); // c
triTwo.flip();
int handle2 = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, handle2);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, triTwo, GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
handles[1] = handle2;
System.out.println("Created Handle 1 : " + handle1 + " handle 2 : " + handle2);
return handles;
}
[/spoiler]
Because Im using AWT I have two frames, one that holds a canvas and another that holds all my buttons and such. I used the Display.setParent() to attach the display to the canvas, and then used a normal render loop : [spoiler]
while (!Display.isCloseRequested()) {
preRender();
System.out.println("Pre render Done");
render(); //Something here crashes it
System.out.println("Render Done");
Display.update();
System.out.println("Update Done");
Display.sync(60);
System.out.println("Sync Done");
}
[/spoiler]
This is my console after the program crashes : [spoiler]
We started
Created Handle 1 : 1 handle 2 : 2
Created Handle 1 : 3-21 handle 2 : 4-22 (Omitted for space)
Created Handle 1 : 23 handle 2 : 24
Pre render Done
Finsihed rendering handle : 1
Finsihed rendering handle : 2-23 (Omitted for space)
Finsihed rendering handle : 24
Render Done
Update Done
Sync Done
Pre render Done
Finsihed rendering handle : 1
Finsihed rendering handle : 2-23 (Omitted for space)
Finsihed rendering handle : 24
Render Done
[/spoiler]
When I run the program on my Laptop it works just fine (Every other triangle doesn’t render but I’m not worried about that right now)
I have tried with LWJGL version 2.9.1, 2.9.2 and 2.9.0
Any help would be greatly appreciated
//Off topic, how do I make spoiler tags hide code tags?