Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // vs
- attribute vec4 a_Position;
- attribute vec4 a_Color;
- varying vec4 v_Color;
- uniform mediump mat4 u_Rotation;
- void main()
- {
- v_Color = a_Color;
- gl_Position = u_Rotation * a_Position;
- }
- // ps
- varying vec4 v_Color;
- void main()
- {
- gl_FragColor = v_Color;
- }
- // va
- private float[] vertices = {
- -0.9f, -0.5f, 0.0f,
- 0.5f, -0.5f, 0.0f,
- -0.2f, 0.5f, 0.0f, //1 triangle
- -0.8f, -0.5f, 0.2f,
- 0.6f, -0.5f, 0.2f,
- -0.1f, 0.5f, 0.2f, //2 triangle
- -0.7f, -0.5f, 0.4f,
- 0.7f, -0.5f, 0.4f,
- 0.0f, 0.5f, 0.4f, //3 triangle
- -0.6f, -0.5f, 0.6f,
- 0.8f, -0.5f, 0.6f,
- 0.1f, 0.5f, 0.6f, //4 triangle
- };
- // ca
- private float[] colors = {
- 0.2f, 0.2f, 0.2f,
- 0.3f, 0.3f, 0.3f,
- 0.4f, 0.4f, 0.4f,
- 0.8f, 0.1f, 0.1f,
- 0.8f, 0.2f, 0.2f,
- 0.8f, 0.3f, 0.3f,
- 0.1f, 0.8f, 0.1f,
- 0.2f, 0.8f, 0.2f,
- 0.3f, 0.8f, 0.3f,
- 0.1f, 0.1f, 0.8f,
- 0.2f, 0.2f, 0.8f,
- 0.3f, 0.3f, 0.8f,
- };
- // rf
- @Override
- public void onDrawFrame(GL10 gl) {
- glClear(GL_COLOR_BUFFER_BIT);
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LESS);
- glDepthMask(true);
- float angle = 15.0f / 60.0f;
- rotate(angle);
- setMeshToRender();
- currentMesh.bindAttributes(aPosition, aColor);
- glDrawArrays(GL_TRIANGLES, 0, 12);
- currentMesh.unbindAttributes(aPositionLocation, aColorLocation);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement