Anyone have any idea of how to debug VBOs? I’m getting a crash inside the NVidia driver which must be due to what I’m doing with my VBOs, but I can’t track it down.
What’s the crash? Where’s the code? etc. I haven’t found a way to actually debug them apart from doggest persistence and brute force. Then when I’ve figured it all out I hide it in a complex class library and never look at it ever again 
Cas 
This is the crash:
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x69bd3570, pid=4160, tid=6620
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode)
# Problematic frame:
# C [nvoglv32.dll+0x6d3570]
#
# An error report file with more information is saved as hs_err_pid4160.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
Here’s the code that creates and renders the VBOs (below). Each VBO is a patch in a terrain grid.
public Patch(int gridX, int gridY, GL gl){
int[] tmp = new int[]{0,0,0};
gl.glGenBuffers(3, tmp, 0);
vboArrayIdx = tmp[0];
vboElemIdx = tmp[1];
vboUVIdx = tmp[2];
FloatBuffer vBuffer = Buffers.makeFloatBuffer(patchBufSz * 3);
IntBuffer iBuffer = Buffers.makeIntBuffer((PatchSize-1) * (PatchSize-1) * 6);
FloatBuffer uvBuffer = Buffers.makeFloatBuffer(patchBufSz * 2);
final int xOffset = gridX * (PatchSize-1);
final int yOffset = gridY * (PatchSize-1);
for(int y=0; y<PatchSize; y++){
for(int x=0; x<PatchSize; x++){
final int x2 = x + xOffset;
final int y2 = y + yOffset;
vBuffer.put((float)x2 * gridScale);
vBuffer.put((float)y2 * gridScale);
vBuffer.put(heightField.get(x2 + y2 * xDim));
if(y<(PatchSize-1) && x<(PatchSize-1)){
final int a = (y + 1) * PatchSize + x;
final int b = y * PatchSize + x;
final int c = (y + 1) * PatchSize + x + 1;
final int d = y * PatchSize + x + 1;
iBuffer.put(a);
iBuffer.put(b);
iBuffer.put(c);
iBuffer.put(c);
iBuffer.put(b);
iBuffer.put(d);
}
uvBuffer.put((float)x / (float)xDim);
uvBuffer.put((float)y / (float)yDim);
}
}
vBuffer.rewind();
iBuffer.rewind();
uvBuffer.rewind();
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboArrayIdx);
gl.glBufferData(GL.GL_ARRAY_BUFFER, patchBufSz * 4 * 6, vBuffer, GL.GL_STATIC_DRAW);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, vboElemIdx);
gl.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER, (PatchSize-1) * (PatchSize-1) * 4 * 6, iBuffer, GL.GL_STATIC_DRAW);
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboUVIdx);
gl.glBufferData(GL.GL_ARRAY_BUFFER, patchBufSz * 4 * 2, uvBuffer, GL.GL_STATIC_DRAW);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
}
/**
*
* @param gl
*/
void render(GL gl) {
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE );
gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_DECAL);
colorTex.bind();
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboUVIdx);
gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, 0);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboArrayIdx);
gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0);
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, vboElemIdx);
gl.glDrawElements(GL.GL_TRIANGLES, (PatchSize-1) * (PatchSize-1) * 2 * 3, GL.GL_UNSIGNED_INT, 0);
gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
}
Where’s the rest of the crash log?
Cas 
attached 
It looks like you’re passing in a size of patchBufSz * 4 * 6 to glBufferData when you’ve only created it to be of size patchBufSz * 4 *3 to me.
Cas 
(LWJGL has checks for this ;))
Cas 
Hmmmm… maybe I should reconsider switching from JOGL then? I’ve been using JOGL for some time, but I’ve heard lots of good things about LWJGL
Yeah, that was it. Thanks heaps!
Took me all of 30 seconds to spot that 
Cas 