Advertisement
Guest User

Untitled

a guest
Jun 28th, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. // vs
  2.  
  3. attribute vec4 a_Position;
  4. attribute vec4 a_Color;
  5.  
  6. varying vec4 v_Color;
  7.  
  8. uniform mediump mat4 u_Rotation;
  9.  
  10. void main()
  11. {
  12. v_Color = a_Color;
  13. gl_Position = u_Rotation * a_Position;
  14. }
  15.  
  16.  
  17.  
  18.  
  19. // ps
  20.  
  21. varying vec4 v_Color;
  22.  
  23. void main()
  24. {
  25. gl_FragColor = v_Color;
  26. }
  27.  
  28.  
  29.  
  30.  
  31. // va
  32.  
  33. private float[] vertices = {
  34. -0.9f, -0.5f, 0.0f,
  35. 0.5f, -0.5f, 0.0f,
  36. -0.2f, 0.5f, 0.0f, //1 triangle
  37.  
  38. -0.8f, -0.5f, 0.2f,
  39. 0.6f, -0.5f, 0.2f,
  40. -0.1f, 0.5f, 0.2f, //2 triangle
  41.  
  42. -0.7f, -0.5f, 0.4f,
  43. 0.7f, -0.5f, 0.4f,
  44. 0.0f, 0.5f, 0.4f, //3 triangle
  45.  
  46. -0.6f, -0.5f, 0.6f,
  47. 0.8f, -0.5f, 0.6f,
  48. 0.1f, 0.5f, 0.6f, //4 triangle
  49.  
  50. };
  51.  
  52.  
  53.  
  54.  
  55. // ca
  56.  
  57. private float[] colors = {
  58. 0.2f, 0.2f, 0.2f,
  59. 0.3f, 0.3f, 0.3f,
  60. 0.4f, 0.4f, 0.4f,
  61.  
  62. 0.8f, 0.1f, 0.1f,
  63. 0.8f, 0.2f, 0.2f,
  64. 0.8f, 0.3f, 0.3f,
  65.  
  66. 0.1f, 0.8f, 0.1f,
  67. 0.2f, 0.8f, 0.2f,
  68. 0.3f, 0.8f, 0.3f,
  69.  
  70. 0.1f, 0.1f, 0.8f,
  71. 0.2f, 0.2f, 0.8f,
  72. 0.3f, 0.3f, 0.8f,
  73. };
  74.  
  75.  
  76.  
  77. // rf
  78.  
  79. @Override
  80. public void onDrawFrame(GL10 gl) {
  81. glClear(GL_COLOR_BUFFER_BIT);
  82.  
  83. glEnable(GL_DEPTH_TEST);
  84. glDepthFunc(GL_LESS);
  85. glDepthMask(true);
  86.  
  87. float angle = 15.0f / 60.0f;
  88.  
  89. rotate(angle);
  90. setMeshToRender();
  91.  
  92. currentMesh.bindAttributes(aPosition, aColor);
  93.  
  94. glDrawArrays(GL_TRIANGLES, 0, 12);
  95.  
  96. currentMesh.unbindAttributes(aPositionLocation, aColorLocation);
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement