title: OpenGL - glm translation and scale composition
body: <p>I've got a program, in which I display an object.
  First I load position p.x, p.y, p.z, and scale s.x, s.y, s.z from the file.
  Then I apply them to 4x4 ModelMatrix and perform many translation and scale operations to it.</p>
  
  <p>When I load object for the first time, I use <code>p</code> and <code>s</code> values:</p>
  
  <pre><code>modelMatrix = glm::mat4(1.0));
  
  /*Translations*/
  modelMatrix = glm::translate(modelMatrix, glm::vec3(p.x, p.y, p.z));
  modelMatrix = glm::scale(modelMatrix, glm::vec3(s.x, s.y, s,z));
  </code></pre>
  
  <p>While during the program I perform scale and translation operations, and then save p and s values back to the file.</p>
  
  <pre><code>void Display::Translate( double x, double y, double z)
  {
      modelMatrix = glm::translate(modelMatrix, glm::vec3(x,y,z));
      p.x += x;   //that way p is composition of all translations
      p.y += y;
      p.z += z;
  } 
  
  void Display::Scale( double x, double y, double z)
  {
      modelMatrix = glm::scale(modelMatrix, glm::vec3(x,y,z));
      s.x *= x;    //that way s is composition of all scalings
      s.y *= y;
      s.z *= z;
  }
  </code></pre>
  
  <p>Now the problem is that after loading again (running the program again), objects are not in the place I save them, but some rather random place. (especially translation).
  Am I composing transformations in the wrong way (adding to x,y,z in translation and multiplying in scalings)?</p>