title: Passing a 2d vector as vec4 to a OpenGL ES 2.0 shader
body: <p>I have a texture position (2d vector), which I multiply by a 4x4 matrix in the shader.
  Currently I'm passing the vector as a vec2 attribute and then creating a vec4 out of it:</p>
  
  <p><strong>Java</strong>:</p>
  
  <pre><code>private static final float[] TEXTURE_COORDINATES = {
          0, 1, // bottom left
          1, 1, // bottom right
          0, 0, // top left
          1, 0, // top right
  };
  </code></pre>
  
  <p><strong>Vertex-shader</strong>:</p>
  
  <pre><code>attribute vec2 texturePosition;
  uniform mat4 textureMatrix;
  // more variables
  void main() {
      vec4 tp = vec4(texturePosition.x, texturePosition.y, 1, 1);
      tp = textureMatrix * tp;
      // more code
  }
  </code></pre>
  
  <p>Would  it be better (in which way?) to directly pass a vec4 attribute and store the two 1s on the java-side?</p>
  
  <p><strong>Java</strong>:</p>
  
  <pre><code>private static final float[] TEXTURE_COORDINATES = {
          0, 1, 1, 1, // bottom left
          1, 1, 1, 1, // bottom right
          0, 0, 1, 1, // top left
          1, 0, 1, 1, // top right
  };
  </code></pre>
  
  <p><strong>Vertex-shader</strong>:</p>
  
  <pre><code>attribute vec4 texturePosition;
  uniform mat4 textureMatrix;
  // more variables
  void main() {
      vec4 tp = textureMatrix * tp;
      // more code
  }
  </code></pre>