In OpenGL ES, you cannot define individual vertex via glVertex command (this command is not supported in ES due to inefficiency).
Gl.glDisableClientState(GL10.GL_VERTEX_ARRAY) Gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_BYTE, indexBuffer) Gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer) Gl.glEnableClientState(GL10.GL_VERTEX_ARRAY) Enable vertex-array and define the buffers IndexBuffer = ByteBuffer.allocateDirect(indices.length) VertexBuffer.put(vertices) // Copy data into buffer VertexBuffer = vbb.asFloatBuffer() // Convert byte buffer to float Vbb.order(ByteOrder.nativeOrder()) // Use native byte order A float has 4 bytes.īyteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4) Constructor - Setup the data-array buffers Public class MyGLActivity extends Activity // Indices to above vertices (in CCW) The following program sets up the GLSurfaceView, and show a blank (dark green) screen. Create a blank activity called ' MyGLActivity'. 2.3 Example 1: Setting up OpenGL ES using GLSurfaceView (Nehe Lesson 1: Setting Up)Ĭreate an android application called 'Nehe 01', with project name ' Nehe01', package name ' com.test'.