title: How to apply position transformation
body: <p>How do I apply the drawing position in the world via shaders?</p>
  
  <p>My vertex shader looks like this:</p>
  
  <pre><code>in vec2 position;
  
  uniform mat4x4 model;
  uniform mat4x4 view;
  uniform mat4x4 projection;
  
  void main() {
      gl_Position = projection * view * model * vec4(position, 0.0, 1.0);
  }
  </code></pre>
  
  <p>Where <code>position</code> is the positions of the vertexes of the triangles. </p>
  
  <p>I'm binding the matrices as follows.</p>
  
  <p><em>view</em>:</p>
  
  <pre><code>glm::mat4x4 view = glm::lookAt(
                      glm::vec3(0.0f, 1.2f, 1.2f),    // camera position
                      glm::vec3(0.0f, 0.0f, 0.0f),    // camera target
                      glm::vec3(0.0f, 0.0f, 1.0f));   // camera up axis
  GLint view_uniform = glGetUniformLocation(shader, "view");
  glUniformMatrix4fv(view_uniform, 1, GL_FALSE, glm::value_ptr(view));
  </code></pre>
  
  <p><em>projection</em>:</p>
  
  <pre><code>glm::mat4x4 projection = glm::perspective(80.0f, 640.0f/480.0f, 0.1f, 100.0f);
  GLint projection_uniform = glGetUniformLocation(shader, "projection");
  glUniformMatrix4fv(projection_uniform, 1, GL_FALSE, glm::value_ptr(projection));
  </code></pre>
  
  <p><em>model transformation</em>:</p>
  
  <pre><code>glm::mat4x4 model;
  model = glm::translate(model, glm::vec3(1.0f, 0.0f, 0.0f));
  model = glm::rotate(model, static_cast&lt;float&gt;((glm::sin(currenttime)) * 360.0), glm::vec3(0.0, 0.0, 1.0));
  GLint trans_uniform = glGetUniformLocation(shader, "model");
  glUniformMatrix4fv(trans_uniform, 1, GL_FALSE, glm::value_ptr(model));
  </code></pre>
  
  <p>So this way I have to compute the position transformation each frame on the CPU. Is this the recommended way or is there a better one?</p>