title: Mouse to world position without gluUnProject?
body: <p>I'm trying to implement an editor like placing mod with opengl. 
  When you click somewhere on the screen an object get placed in that position.</p>
  
  <p>So far this is my code</p>
  
  <pre><code>void RayCastMouse(double posx, double posy)
  {
      glm::fvec2 NDCCoords = glm::fvec2( (2.0*posx)/ float(SCR_WIDTH)-1.f, ((-2.0*posy) / float(SCR_HEIGHT)+1.f) );
      glm::mat4 viewProjectionInverse = glm::inverse(projection * camera.GetViewMatrix());
      glm::vec4 worldSpacePosition(NDCCoords.x, NDCCoords.y, 0.0f, 1.0f);
      glm::vec4 worldRay = viewProjectionInverse*worldSpacePosition;
      printf("X=%f / y=%f / z=%f\n", worldRay.x, worldRay.y, worldRay.z);
      m_Boxes.emplace_back(worldRay.x, 0, worldRay.z);
  }
  </code></pre>
  
  <p>The problem is the object isn't placed at the correct position, worldRay vec3 is used to translate the model matrix.</p>
  
  <p>Can anyone one please help with this i will really appreciate it.
  By the way division the worldRay xyz component by worldRay.w is setting the object at the camera position.</p>