title: Converting Mouse Coords to World Coords
body: <p>I'm trying to make a light source follow the mouse in OpenGL (C++). In world coords, the center of my screen is <code>(4, 1.5f)</code> and I get my mouse coords for the center as <code>(640, 360)</code> (window res is 1280, 720). I managed to convert the coordinates for only the center, but I can't figure out how to get the rest to convert.</p>
  
  <p>For converting the center coordinate:</p>
  
  <p><code>shader.SetUniform("lightPos", fs::Vector2f((float) x * 8 / 1280, (float) (y * 4.5f / 720) - 0.75f));</code></p>
  
  <p>Another conversion I tried was <code>(x * 16.0f / 1280.0f), (9.0f - y * 9.0f / 720.0f)</code></p>
  
  <p>where x and y are the mouse coordinates.</p>
  
  <p>All the solutions I've found online have not been working thus far.</p>
  
  <p>In case it matters, this is my projection matrix:</p>
  
  <p><code>fs::Matrix4f ortho = fs::Matrix4f::Orthographic(0, 16, 0, 9, -1, 1);</code></p>
  
  <p>Parameters: <code>float left, float right, float bottom, float top, float near, float far</code></p>
  
  <p>For clarification, here are some images where the yellow rectangle is my mouse, which is where i want the light to render</p>
  
  <p><img src="https://i.stack.imgur.com/MEIkv.png" alt="Center coordinate being correct"></p>
  
  <p><img src="https://i.stack.imgur.com/9zara.png" alt="Now its not correct"></p>
  
  <p>Any ideas?</p>