Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // init:
- GLES20.glEnable(GLES20.GL_DEPTH_TEST);
- Mesh cube = new Mesh(false, 8, 36,
- new VertexAttribute(VertexAttribute.POSITION, 3, ShaderProgram.POSITION_ATTRIBUTE),
- new VertexAttribute(VertexAttribute.COLOR_PACKED, 4, ShaderProgram.COLOR_ATTRIBUTE)
- );
- float x = -100;
- float y = -50;
- float z = 250;
- float w = 50;
- float h = 50;
- float l = 50;
- float r = Color.RED.toFloatBits();
- float g = Color.GREEN.toFloatBits();
- float b = Color.BLUE.toFloatBits();
- float[] vertices = {
- -w / 2f + x, y, l / 2f + z, // 0
- r,
- -w / 2f + x, h + y, l / 2f + z, // 1
- r,
- w / 2f + x, h + y, l / 2f + z, // 2
- b,
- w / 2f + x, y, l / 2f + z, // 3
- b,
- w / 2f + x, y, -l / 2f + z, // 4
- g,
- w / 2f + x, y + h, -l / 2f + z, // 5
- g,
- -w / 2f + x, y + h, -l / 2f + z, // 6
- r,
- -w / 2f + x, y, -l / 2f + z, // 7
- r
- };
- short[] indices = {
- 0, 1, 2, 2, 3, 0,
- 3, 2, 5, 5, 4, 3,
- 4, 5, 6, 6, 7, 4,
- 7, 6, 1, 1, 0, 7,
- 0, 3, 4, 4, 7, 0,
- 1, 6, 5, 5, 2, 1
- };
- cube.setIndices(indices);
- cube.setVertices(vertices);
- // render:
- GLES20.glClearColor(0f, 0f, 0f, 1f);
- GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
- shaderProgram.begin();
- cube.render(shaderProgram, GLES20.GL_TRIANGLES, 0, 36);
- shaderProgram.end();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement