Hi everyone,

I'm having a little trouble again.

Currently I want to find the bounds of my window in world coordinates. I know that unprojection can be useful for that, but I'm doing it wrong and can't find my mistake.

I'm trying to get the right end of my window this way:

The goal is that v.x contains the right bound of my window in world coordinates. This value should be around 4.Code :viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -5.f)); //View matrix is translated 5 units back. projectionMatrix = glm::perspective(60.0f, 640.f / 480.f, 0.1f, 100.f); //FOV is 60, window aspect is 640/480, near plane 0.1 and far plane is 100. glm::vec3 position(639.f, 479.f, 0.f); glm::vec3 v = glm::unProject(position, viewMatrix, projectionMatrix, glm::vec4(0, 0, 640.f, 480.f));

I don't know what value I can use for the z-value in position. If I use 1 then v.x is ~67. With z = 0 it is ~0.067.

Currently I'm not using the z-axis for any of my game objects. It's 2D but not orthogonal.

Is there a way to calculate z for position or any other way to get the window bounds in world coordinates?