Reputation: 7331
I am drawing a simple rectangular line loop using this call:
GLES20.glDrawElements(GLES20.GL_LINE_LOOP,
numIndices, GLES20.GL_UNSIGNED_SHORT,
getIndicesBuffer());
Now, the color of this line loop is black. How can I change it to another color? Red, for example.
Upvotes: 0
Views: 1221
Reputation: 48196
You will need to change your fragment shader, I am going to assume you want to change the color per line loop.
change your fragment shader to this:
uniform vec4 color;
main(){
gl_FragColor = color;
}
And before each glDrawElements you can then call GLES20.glUniform4f(colorLoc, r, g, b, a);
. Where colorLoc
is the return value of GLES20.glGetUniformLocation(program, "color");
and r, g, b and A are the red, green, blue and alpha values in the range 0-1 of the color you want.
Upvotes: 2