This should be easy So I am using the following to create a fragment shader.
GLbyte fShaderStr[] = "precision mediump float;"
"void main() \n"
"{ \n"
" gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); \n"
"} \n";
I then render a circle (collection of lines) the circle comes our red. If I change the code to...
GLbyte fShaderStr[] = "precision mediump float;"
"void main() \n"
"{ \n"
" gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0); \n"
"} \n";
The circle is now purple. My question is how do I control this dynamically? So for example when I receive an input I toggle the two colors?
I tried...
GLbyte vShaderStr[] = "attribute vec4 vPosition; \n"
"attribute vec4 inColor; \n"
"uniform mat4 Projection; \n"
"varying vec4 fragColor; \n"
"void main() \n"
"{ \n"
" gl_Position = Projection * vPosition; \n"
" fragColor = inColor; \n"
"} \n";
GLbyte fShaderStr[] = "precision mediump float;"
"varying vec4 fragColor; \n"
"void main() \n"
"{ \n"
" gl_FragColor = fragColor; \n"
"}\n";
void initColor(){
LOGD("Initing Color");
GLfloat vVertices[] = { 1.0f, 0.0f, 0.0f, 1.0f };
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, vVertices);
}
However, this doesn't seem to work as the circle is now black.