Android : Vertex Buffer Object rendering in GLES 1.1

on Saturday, September 13, 2014


trying to get simple vertex buffer object rendering done in GLES 1.1 (not 2.0)


here is what i have so far:


setup part:



ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length*4);
vbb.order(ByteOrder.nativeOrder());
mVertexBuffer = vbb.asFloatBuffer();
mVertexBuffer.put(vertices);
mVertexBuffer.position(0);
GLES11.glBindBuffer(GLES11.GL_ARRAY_BUFFER, vbo[0]);
GLES11.glBufferData(GLES11.GL_ARRAY_BUFFER, mVertexBuffer.capacity() * 4, mVertexBuffer, GLES11.GL_STATIC_DRAW);

mIndexBuffer = ByteBuffer.allocateDirect(indices.length);
mIndexBuffer.put(indices);
mIndexBuffer.position(0);
GLES11.glBindBuffer(GLES11.GL_ELEMENT_ARRAY_BUFFER, ibo[0]);
GLES11.glBufferData(GLES11.GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer.capacity() * 1, mIndexBuffer, GLES11.GL_STATIC_DRAW);


then each frame:



GLES11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
GLES11.glBindBuffer(GLES11.GL_ARRAY_BUFFER, vbo[0]);

GLES11.glBindBuffer(GLES11.GL_ELEMENT_ARRAY_BUFFER, ibo[0]);
GLES11.glDrawElements(GLES11.GL_TRIANGLE_STRIP, 4, GLES11.GL_UNSIGNED_SHORT, 0);


however, it crashes just after startup in the GL thread.


0 comments:

Post a Comment