title: glm::unProject to convert mouse position to 3 coordinates
body: <p>I am using OpenGL 3.2 + GLM for my matrix math. Below is my code:</p>
  
  <pre><code>GLint viewport[4];
  GLfloat winZ;
  
  glGetIntegerv(GL_VIEWPORT,viewport);
  glBindFramebuffer(GL_FRAMEBUFFER,fbo);
  glReadPixels(x,y,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&amp;winZ);
  glBindFramebuffer(GL_FRAMEBUFFER,0);
  
  glm::vec3 screen=glm::vec3(x,viewport[3]-y,winZ);
  glm::mat4 view=glm::lookAt(glm::vec3(camera.x,camera.y,camera.z),glm::vec3(0,0,0),glm::vec3(0,1,0));
  glm::mat4 projection=glm::perspective(90.0f,(float)viewport[2]/(float)viewport[3],10.0f,500.0f);
  
  glm::vec3 pos=glm::unProject(screen,view,projection,glm::vec4(0,0,viewport[2],viewport[3]));
  
  return {pos.x,pos.y,pos.z};
  </code></pre>
  
  <p><code>winZ</code> is correct. When I click off of the model, it is 1.0 (zfar) and when I click on the model it looks similar to what I would expect it to be. However, the returned value <code>pos.z</code> is not what I expect. When the mouse is over the background: if it's toward the center, <code>pos.z</code> gets smaller, and when it's at the screen edges <code>pos.z</code> is zfar. Can anyone explain this?</p>
  
  <p>The actual issue I am having is that the <code>pos.x</code> and <code>pos.y</code> don't return what I expect ether. My model is 4.88 units wide, yet <code>unProject</code> is saying that it is around 20 units wide? (if i add the values of hovering on the left and right sides).</p>
  
  <p>Oh, and the screen center is 0,0 as expected.</p>
  
  <hr>
  
  <p>EDIT: I also should note that the returned <code>pos.z</code> is dependent on the position of the mouse from the center of the screen. It does change to a much higher number when it's on top of the model. If the Y-pos of the cursor is above screen center, <code>pos.z</code> is positive. If Y-pos is below, <code>pos.z</code> is negative. Seems reaaallly weird.</p>