Large Vertex Data Buffer

167 views Asked by At

I'm trying to draw a lot of squares by loading vertex data (position and texture coordinates) into a VBO. My issue is when I try to load all of these vertices, for some reason it skips over some squares, leaving an empty space. if I reduce the number of squares, then this issue does not occur.

Here's how I attempt to set up the VBO:

float[] vertexData = new float[<large number>];
//fill vertexData with 5 floats per square
FloatBuffer vertexBuffer = ByteBuffer.allocateDirect(vertexData.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
vertexBufferBackground.put(vertexData).position(0);

int[] buffers = new int[1];
GLES20.glGenBuffers(1, buffers, 0);

GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, vertexBuffer.capacity() * 4, vertexBuffer, GLES20.GL_STATIC_DRAW);
bufferIDBackground = buffers[0];

And here's how it's rendered:

GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, bufferID);
GLES20.glEnableVertexAttribArray(mPositionHandle);
GLES20.glVertexAttribPointer(mPositionHandle, 3, GLES20.GL_FLOAT, false, 20, 0);

GLES20.glEnableVertexAttribArray(mTexCoordLoc);
GLES20.glVertexAttribPointer(mTexCoordLoc, 2, GLES20.GL_FLOAT, false, 20, 12);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);

A lot of code has been omitted for simplicity, I'm only showing what I think is relevant. Let me know if it's not enough.

Edit: Here's an image of my issue: enter image description here

Update: I've seperated the buffers into smaller chunks and rendered them individually. Here are the results (edited with MS Paint):
2x2 chunks: enter image description here

4x4 chunks: enter image description here

The bottom left corner tiles of the 4x4 are suppose to be empty. The adjacent chunk is suppose to be completely filled. It looks like there is some limit to the number of vertex one buffer can hold/render, 3 for the 2x2, and 9 for the 4x4. (ignore the green stuff, there in a different buffer).
1x1 chunks (every tile is in their own buffer) renders everything completely fine, but performance takes a huge hit.

0

There are 0 answers