title: GLSL Fragment Position
body: <p>In my .cpp code I create a list of quads, a few of them have a flag, in the pixel shader  I check if this flag is set or not, if the flag is not set, the quad gets colored in red for example, if the flag is set, I want to decide the color of every single pixel, so if I need to colour half of the flagged quad in red and the other half in blue I can simply do something like :</p>
  <pre><code>if coordinate in quad &lt; something color = red
  else colour = blue; 
  </code></pre>
  <p>In this way I can get half of the quad colored in blue and another half colored in red, or I can decide where to put the red color or where to put the blue one.</p>
  <p>Imagine I've got a quad 50x50 pixels</p>
  <p>[frag]</p>
  <pre><code>if(quad.flag == 1)
    {    
      if(Pixel_coordinate.x&lt;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);
  </code></pre>
  <p>In this case I would  expect that a quad with the flag set will get two colors per face.
  I hope I have been more specific now.</p>
  <p>thanks.</p>
  <p>Just to add something I can't use any texture.</p>
  <p>Ok i do this now :</p>
  <p>Every quad has 4 textures coordinated (0,0), (0,1), (1,1), (1,0);</p>
  <p>I enable the texture coordinates using :</p>
  <pre><code>glTexCoordPointer(2, GL_SHORT, sizeof(Vertex), BUFFER_OFFSET(sizeof(float) * 7));
  </code></pre>
  <p>[vert]</p>
  <pre><code>varying vec2 texCoord;
  
  main()
  {
      texCoord = gl_MultiTexCoord0.xy;
  } 
  </code></pre>
  <p>[frag]</p>
  <pre><code>varying vec2 texCoord;
  
  main()
  {
      float x1 = texCoord.s;
      float x2 = texCoord.t;
      
      gl_FragColor = vec4(x1, x2, 0.0, 1.0);
  }
  </code></pre>
  <p>I get always the yellow color so x1 =1 and x2 = 1 almost always and some quad is yellow/green.</p>
  <p>I would expect that the texture coordinates change in the fragment shader and so I should get a gradient, am I wrong?</p>