I'm making a drawing program in C++ and can't figure out how to convert from screen space to world space
I have access to the projection and view matrices as well as the screen size ect
This is the code I'm using but it doesn't work
There are no errors but it doesn't output world space coodinates at all, it just slightly changes all of the pixel coodinates
I was following an answer I found here OpenGL Math - Projecting Screen space to World space coords
I'm only using an orthographic camera right now
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;