So I am really mad right now. Have been working for 2 days on getting a dynamic vbo to work…basically a sprite batcher of sorts and can’t get anything right. I have read probably every tutorial that you can find by googling VBO, dynamic VBO, interleaved VBO…I even have looked through libgdx’s source for enlightenment.
Right now I have stuff actually showing up on screen without all sorts of black crashes. I am trying to use an interleaved VBO with Vertex Color Texture. Vertex is 2f Color is 4f, and Texture is 2f.
I have no idea if I am doing anything right so here is what I have. Tell me what is horribly wrong without being too rude.
vctBuffer = BufferUtils.createFloatBuffer(vert.size());
vctBuffer.put(vert.shrink());
vctBuffer.flip();
int stride = (2+4+2)*4;
bufferData(vctPointer, vctBuffer);
Util.checkGLError();
int offset = 0 * 4;
GL11.glVertexPointer(2, GL11.GL_FLOAT,stride, offset);
Util.checkGLError();
offset = 4 * 4;
GL11.glColorPointer(4, GL11.GL_FLOAT, stride, offset);
Util.checkGLError();
offset = (4+2) * 4;
GL11.glTexCoordPointer(2, GL11.GL_FLOAT, stride, offset);
Util.checkGLError();
Util.checkGLError();
Util.checkGLError();
GL11.glDrawArrays(GL11.GL_QUADS, 0, draws*4);
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
draws = 0;
index = 0;
vctBuffer.clear();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
I am got a version working using vertex arrays that could get 40k sprites before fps drops but I want closer to 50k stable 150k drop fps. I know about fill rate limit and I am testing with very small sprites, 4 pixels.
The vert.shrink() stuff is basically my custom array class that grows if it is too small. The size() returns the number of indexs used and the shrink() returns and float[] of the indexes.
If any one could also explain how to use the drawElements command I would also be very happy. I know what it does and why it can be faster but just don’t get how to create the indices stuff. I am really put out at how ridiculously hard this is as there are very few tutorials on this stuff that go further then drawing/rendering a static cube/triangle.