![]() The orthographic projection also does not depend on the resolution. Vec4 view_space = mInverseProjFromView * clip_space īut some don’t (like the orthographic projection) GlfwGetWindowSize( g_pSys->window, &w, &h ) Ĭlip_space.x = 2.0f * (float)x/(float)w- 1.0f Ĭlip_space.y = 1.0f - 2.0f * (float)y/(float)h Ĭlip_space.z = -1.0f // depends on whether you want the near or far plane ![]() cursor pos is in window coordinates, not gl fragment coords so use window size not framebuffer size GlfwGetCursorPos( g_pSys->window, &x, &y ) You will likely need a transform like: // Following code untested So you don’t need to worry about transforming your window coordinates to viewport coordinates if you use the inverse projection transform, as your input to these is in clip space. The clip space coordinates are transformed to screen space coordinates using the viewport transform you set with glViewport. This is because the output of the vertex shader is in clip space which is an axis aligned cube with coordinates ranging from (-1.0,-1.0,-1.0) to (+1.0,+1.0,+1.0). ![]() If you look at the projection matrix calculations you will see that they do not depend on the resolution of the framebuffer, but on the aspect ratio defined by the width / height.
0 Comments
Leave a Reply. |