Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onDrawFrame(GL10 gl) {
- gl.glLoadIdentity();
- gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
- gl.glTranslatef(0, 0, -30f);
- float vertices[] = { -1.0f, 1.0f, 0.0f, // 0, Top Left
- -1.0f, -1.0f, 0.0f, // 1, Bottom Left
- 1.0f, -1.0f, 0.0f, // 2, Bottom Right
- -4.0f, -3.0f, 0.0f, // 0, Top Left
- -4.0f, -4.0f, 0.0f, // 1, Bottom Left
- -3.0f, -4.0f, 0.0f, // 2, Bottom Right
- };
- short[] indices = { 0, 1, 2, 3, 4, 5 };
- FloatBuffer vertexBuffer;
- ShortBuffer indexBuffer;
- ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4);
- vbb.order(ByteOrder.nativeOrder());
- vertexBuffer = vbb.asFloatBuffer();
- vertexBuffer.put(vertices);
- vertexBuffer.position(0);
- ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length * 2);
- ibb.order(ByteOrder.nativeOrder());
- indexBuffer = ibb.asShortBuffer();
- indexBuffer.put(indices);
- indexBuffer.position(0);
- gl.glFrontFace(GL10.GL_CCW);
- gl.glEnable(GL10.GL_CULL_FACE);
- gl.glCullFace(GL10.GL_BACK);
- gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
- gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
- gl.glDrawElements(GL10.GL_TRIANGLES, indices.length,
- GL10.GL_UNSIGNED_SHORT, indexBuffer);
- gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
- gl.glDisable(GL10.GL_CULL_FACE);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement