I did put together this demo Android application just to see some basic stuff like translating, scaling and rotating in action.
OpenGL ES Demo |
How to create and use Virtual Buffer Objects (VBOs) under Android.
Beginning with Android 2.2 (API Level 8), the framework supports the OpenGL ES 2.0 API specification according to the documentation but API Level 8 seems to be missing some functions in order to use VBOs so make sure that you are using at least API Level 9.initialize phase
float[] data = {...};FloatBuffer dataBuffer = FloatBuffer.wrap(data);
// create the buffer object and get a handle to it
IntBuffer buffer = IntBuffer.allocate(1);
GLES20.glGenBuffers(1, buffer);
int bufferObject = buffer.get(0);
// bind bufferObject to the GL_ARRAY_BUFFER
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, bufferObject);
// allocates memory and copy data over to OpenGL memory
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, data.length * 4, dataBuffer, GLES20.GL_STATIC_DRAW);
// cleanup
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
rendering phase
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, bufferObject);
GLES20.glEnableVertexAttribArray(...);
GLES20.glVertexAttribPointer(...);
GLES20.glDrawArrays(...);
Inga kommentarer:
Skicka en kommentar