Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private final String vertexShaderCode =
- "attribute vec4 a_Position;" +
- "attribute vec4 a_Color;" +
- "attribute vec2 a_TexCoordinate;" +
- "varying vec3 v_Position;" +
- "varying vec4 v_Color;" +
- "varying vec2 v_TexCoordinate;" +
- "void main() {" +
- "v_Position = a_Position;" +
- "v_Color = a_Color;" +
- "v_TexCoordinate = a_TexCoordinate;" +
- "gl_Position = a_Position;" +
- "}";
- private final String fragmentShaderCode =
- "precision mediump float;" +
- "uniform sampler2D u_Texture;" +
- "varying vec2 v_TexCoordinate;" +
- "void main()" +
- "{" +
- "gl_FragColor = texture2D(u_Texture, v_TexCoordinate);" +
- "}";
- ----------------------------
- mProgram = GLES20.glCreateProgram();
- checkGlError("glCreateProgram");
- GLES20.glAttachShader(mProgram, vertexShader);
- GLES20.glAttachShader(mProgram, fragmentShader);
- /*
- GLES20.glBindAttribLocation(mProgram, 0, "a_Position");
- GLES20.glBindAttribLocation(mProgram, 1, "a_Color");
- GLES20.glBindAttribLocation(mProgram, 2, "a_TexCoordinate");
- */
- GLES20.glLinkProgram(mProgram);
- FloatBuffer vertexByteBuffer = ByteBuffer.allocateDirect(vertices.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
- vertexByteBuffer.put(vertices).position(0);
- GLES20.glUseProgram(mProgram);
- ------------------------------
- int mPositionHandle = GLES20.glGetAttribLocation(mProgram, "a_Position"); // ERROR! 0x501
Advertisement
Add Comment
Please, Sign In to add comment