title: OpenGL Vertex shader transformation and output
body: <p>I have a simple vertex shader</p>
  
  <pre><code>#version 330 core
  
  uniform mat4 projectionMatrix;
  uniform mat4 viewMatrix;
  uniform mat4 modelMatrix;
  
  in vec3 in_Position;
  
  out vec3 pass_Color;
  
  void main(void)
  {             
      //gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(in_Position, 1.0);
      gl_Position = vec4(in_Position, 1.0);
      pass_Color = vec3(1,1,1);    
  }
  </code></pre>
  
  <p>In my client code i have</p>
  
  <pre><code>    glm::vec4 vec1(-1,-1,0,1);//first
      glm::vec4 vec2(0,1,0,1);//second
      glm::vec4 vec3(1,-1,0,1);//third
      glm::mat4 m = projectionMatrix * viewMatrix * modelMatrix;  
  
      //translate on client side
      vec1 = m * vec1;
      vec2 = m * vec2;
      vec3 = m * vec3;
  
      //first vertex
      vertices[0] = vec1.x;
      vertices[1] = vec1.y;
      vertices[2] = vec1.z;
      //second
      vertices[3] = vec2.x;
      vertices[4] = vec2.y;
      vertices[5] = vec2.z;
      //third
      vertices[6] = vec3.x;
      vertices[7] = vec3.y;
      vertices[8] = vec3.z;
  </code></pre>
  
  <p>Now my question if i use no matrix multiplication in the shader and none in client code this will render me a nice triangle which strectch the whole screen, so i take it the vertex shader maps cordinates its given to the screen in a cordinate system with <code>x=-1..1</code> and <code>y=-1..1</code></p>
  
  <p>If i do the matrix multiplication in the shader everything works nice. But if i comment out the code in the shader like shown and do it on the client i get odd results. Shouldnt it yield the same result?</p>
  
  <p>Have i gotten it wrong thinking the output of the vertex shader <code>gl_Position</code> is 2D cordinates despite being a <code>vec4</code>?</p>
  
  <p>Thanks for any help. I really like to understand what exactly the output of the vertex shader is in terms of vertex position.</p>