title: GLSL 2.0 Color and Texture
body: <p>Hi i'm new to GLSL and i'm having a few problems.</p>
  
  <p>I'm trying to create a pair of GLSL Shaders to either use color or texture but i must be doing something wrong.
  The problem is that if set uUseTexture to 0 (which should indicate color) it doesn't work (object is not colored). I know the coloring code works separately, any hints why it does not work using the if statement?</p>
  
  <p>Here is the code:</p>
  
  <p>// Fragment</p>
  
  <pre><code>precision mediump float;
  
  uniform int uUseTexture;
  uniform sampler2D uSampler;
  
  varying vec4 vColor;
  varying vec2 vTextureCoord;
  
  void main(void) {
  
      if(uUseTexture == 1) {
          gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
      } else {
          gl_FragColor = vColor;
      }
  
  }
  </code></pre>
  
  <p>// Vertex</p>
  
  <pre><code>attribute vec3 aVertexPosition;
  attribute vec4 aVertexColor;
  attribute vec2 aTextureCoord;
  
  uniform int uUseTexture;
  uniform mat4 uMVMatrix;
  uniform mat4 uPMatrix;
  
  varying vec4 vColor;
  varying vec2 vTextureCoord;
  
  void main(void) {
      gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
  
      if(uUseTexture == 1) {
          vTextureCoord = aTextureCoord;
      } else {
          vColor = aVertexColor;
      }
  </code></pre>