Okay, seems like I cannot figure it out myself.
I'm (unsuccessfuly) trying to use VBO's to display bunch of points.
First I was trying to follow
this article and all I got was clear black screen. Then I decided to try lwjgl_debug library and it rewarded me with
Out of memory exception on call to glDrawRangeElements.
So I've found
this source and tried different approach, again with the same result - blank screen with the normal library, Out of memory at glDrawElements with debug library.
As I see it, 49152 bytes of vertex data is not quite enough to run out of memory, so I believe I'm just doing something wrong. I'm not sure I completely understand how buffer objects and buffers related to each other, and thus where problem can be. Any help is appreciated.
Here goes the code:
// after GL init
// create and store VBO id for vertex buffer
IntBuffer ib = BufferUtils.createIntBuffer(1);
ARBVertexBufferObject.glGenBuffersARB(ib);
coordsVBOID = ib.get(0);
// create and store VBO id for index buffer
ib = BufferUtils.createIntBuffer(1);
ARBVertexBufferObject.glGenBuffersARB(ib);
indexVBOID = ib.get(0);
// gen vertex data
FvertexBuffer = BufferUtils.createFloatBuffer(16*16*16*3);
for (int by = 0; by < 16; by++) {
for (int bx = 0; bx < 16; bx++) {
for (int bz = 0; bz < 16; bz++) {
FvertexBuffer.put(2.f * bx);
FvertexBuffer.put(2.f * by);
FvertexBuffer.put(2.f * bz);
}
}
}
// send vertex data to VRAM
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, coordsVBOID);
ARBVertexBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, FvertexBuffer, ARBVertexBufferObject.GL_STATIC_DRAW_ARB);
// gen index data
IindexBuffer = BufferUtils.createIntBuffer(16*16*16);
for (int i = 0; i < 16*16*16; i++) {
IindexBuffer.put(i);
}
// send index data to VRAM
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, coordsVBOID);
ARBVertexBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, IindexBuffer, ARBVertexBufferObject.GL_STATIC_DRAW_ARB);
// render
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, coordsVBOID);
GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0);
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, indexVBOID);
GL12.glDrawRangeElements(GL11.GL_POINTS, 0, 16*16*16, 16*16*16, GL11.GL_UNSIGNED_INT, 0); // Out of memory
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 0);
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
Thanks.