title: Screen space to world space
body: <p>I'm making a drawing program in C++ and can't figure out how to convert from screen space to world space</p>
  <p>I have access to the projection and view matrices as well as the screen size ect</p>
  <p>This is the code I'm using but it doesn't work</p>
  <p>There are no errors but it doesn't output world space coodinates at all, it just slightly changes all of the pixel coodinates</p>
  <p>I was following an answer I found here <a href="https://stackoverflow.com/questions/7692988/opengl-math-projecting-screen-space-to-world-space-coords">OpenGL Math - Projecting Screen space to World space coords</a></p>
  <p>I'm only using an orthographic camera right now</p>
  <pre><code>glm::mat4 proj = cameraComp.Camera.GetProjection();
  glm::mat4 view = glm::translate(glm::mat4(1.0f), transformComp.Position)
         * glm::rotate(glm::mat4(1.0f), glm::radians(transformComp.Rotation.z), glm::vec3(0, 0, 1));
  
  glm::mat4 inversed = glm::inverse(proj * view);
  
  glm::vec4 worldPos = { newMousePos, 0, 1 };
  worldPos *= inversed;
  </code></pre>