Sorry, I rewrote the question, hoping to be clear.
In my .cpp code I create a list of quads, some of which have a flag, in the pixel shader I check whether this flag is set or not, if the flag is not set, the square turns red for example, if the flag is set, I want to determine the color of each pixels, so if I need to color half of the marked square in red and the second half in blue, I can just do something like:
if coordinate in quad < something color = red else colour = blue;
That way, I can get half the square painted in blue and the other half in red, or I can decide where to put the red color or where to put the blue.
Imagine I have a 50x50 pixel square
[Frag]
if(quad.flag == 1) { if(Pixel_coordinate.x<25 ) gl_fragColor = vec4(1.0, 0.0, 0.0, 1.0); else gl_fragColor = vec4(0.0, 1.0, 0.0, 1.0); } else gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
In this case, I expect the square with the flag set to get two colors on the face. Hopefully now I have been more specific.
thanks.
Just to add something, I cannot use texture.
Ok, I'm doing it now:
Each quad has 4 coordinated textures (0,0), (0,1), (1,1), (1,0);
I resolve texture coordinates using:
glTexCoordPointer(2, GL_SHORT, sizeof(Vertex), BUFFER_OFFSET(sizeof(float) * 7));
[vert]
varying vec2 texCoord; main() { texCoord = gl_MultiTexCoord0.xy; }
[Frag]
varying vec2 texCoord; main() { float x1 = texCoord.s; float x2 = texCoord.t; gl_FragColor = vec4(x1, x2, 0.0, 1.0); }
I always get yellow, so x1 = 1 and x2 = 1 almost always, and some ATVs are yellow / green.
I would expect the texture coordinates to change in the fragment shader, and so I have to get the gradient, right?