title: How to convert mouse position to world coordinates?
body: <p>I am trying to see which object is clicked for a fixed Z position. I am using perspective projection.</p>
  
  <p>For the rendering of my objects, I use:</p>
  
  <pre><code>glm::mat4 mvp = m_ProjectionView * model; // Inversed
  </code></pre>
  
  <p>For the calculation of the world position of the mouse, I have tried the following, but it is not converting correctly.</p>
  
  <pre><code>glm::mat4 projViewInverse = glm::inverse( projection * view );
  glm::vec4 cursorWorldPosition = glm::vec4( projViewInverse * glm::vec4( ( mousePosX / scrWidth ) * 2.0f - 1.0f, ( mousePosY / scrHeight ) * 2.0f - 1.0f, -1, 1 ) );
  
  cursorWorldPosition.w = 1.0f / cursorWorldPosition.w;
  cursorWorldPosition.x *= cursorWorldPosition.w;
  cursorWorldPosition.y *= cursorWorldPosition.w;
  cursorWorldPosition.z *= cursorWorldPosition.w;
  </code></pre>