title: How to properly rotate and scale an object in OpenGL?
body: <p>I'm trying to build the model matrix every frame, for that I'm creating a translation, rotation, and scale matrix and multiplying it. But I can't seem to figure it how to build the rotation matrix and scale it properly.</p>
  
  <p>Here's what I'm doing:</p>
  
  <pre><code>glm::mat4 scale = glm::scale(mat4(1.0f), my_models[i].myscale);
  glm::mat4 rotateM(1.0); 
  glm:mat4 translate = glm::translate(mat4(1.0f), my_models[i].initialPos);
  
  rotateM = mat4_cast(my_models[i].Quat); 
  rotateM = glm::rotate(rotateM, (float) my_models[i].angle * t, my_models[i].animation_axis[0]);
  
  my_models[i].modelMatrix = translate * rotateM *scale;
  my_models[i].Quat = quat_cast(my_models[i].modelMatrix); 
  </code></pre>
  
  <p>In the Constructor I'm using:</p>
  
  <pre><code>quat Quat = glm::angleAxis(glm::radians(90.f), glm::vec3(0.f, 1.f, 0.f));
  </code></pre>
  
  <p>If my_models[i].myscale exactly 1.0f it rotates just fine, but if it is bigger the object keeps growing and rotates weirdly. Quaternions are very new to me, so I'm assuming I'm messing up there. </p>
  
  <p>What am I missing? Are there simpler ways to construct the models rotation matrix? if so, what information should I be saving?</p>
  
  <p>Edit:
  As jparima suggested, the following fixed my problem.</p>
  
  <pre><code>glm::mat4 scale = glm::scale(mat4(1.0f), my_models[i].myscale);
  glm::mat4 rotateM(1.0); 
  glm::mat4 translate = glm::translate(mat4(1.0f), my_models[i].initialPos);
  
  my_models[i].Quat = rotate(my_models[i].Quat, my_models[i].angle * t, my_models[i].animation_axis[0]);
  
  rotateM = mat4_cast(my_models[i].Quat); 
  
  my_models[i].modelMatrix = translate * rotateM * scale;
  </code></pre>