ThatSnail

Untitled

Nov 21st, 2012
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. private final String vertexShaderCode =
  2. "attribute vec4 a_Position;" +
  3. "attribute vec4 a_Color;" +
  4. "attribute vec2 a_TexCoordinate;" +
  5. "varying vec3 v_Position;" +
  6. "varying vec4 v_Color;" +
  7. "varying vec2 v_TexCoordinate;" +
  8. "void main() {" +
  9. "v_Position = a_Position;" +
  10. "v_Color = a_Color;" +
  11. "v_TexCoordinate = a_TexCoordinate;" +
  12. "gl_Position = a_Position;" +
  13. "}";
  14.  
  15. private final String fragmentShaderCode =
  16. "precision mediump float;" +
  17. "uniform sampler2D u_Texture;" +
  18. "varying vec2 v_TexCoordinate;" +
  19. "void main()" +
  20. "{" +
  21. "gl_FragColor = texture2D(u_Texture, v_TexCoordinate);" +
  22. "}";
  23.  
  24. ----------------------------
  25.  
  26. mProgram = GLES20.glCreateProgram();
  27. checkGlError("glCreateProgram");
  28. GLES20.glAttachShader(mProgram, vertexShader);
  29. GLES20.glAttachShader(mProgram, fragmentShader);
  30. /*
  31. GLES20.glBindAttribLocation(mProgram, 0, "a_Position");
  32. GLES20.glBindAttribLocation(mProgram, 1, "a_Color");
  33. GLES20.glBindAttribLocation(mProgram, 2, "a_TexCoordinate");
  34. */
  35. GLES20.glLinkProgram(mProgram);
  36.  
  37. FloatBuffer vertexByteBuffer = ByteBuffer.allocateDirect(vertices.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
  38. vertexByteBuffer.put(vertices).position(0);
  39.  
  40. GLES20.glUseProgram(mProgram);
  41.  
  42. ------------------------------
  43.  
  44. int mPositionHandle = GLES20.glGetAttribLocation(mProgram, "a_Position"); // ERROR! 0x501
Advertisement
Add Comment
Please, Sign In to add comment