Ambigious OpenGL Default Camera position

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 12:07:08

What appears on your screen will depend on the whole transformations you apply to it. I interpret your question in the way that you use an identity matrix both for the projection and the (model)view transformation. In that case, you are directly drawing in clip space. Technically, this will define a camera position at the origin, but the view frustum will be equivalent to an Ortho(-1.0, 1.0, -1.0, 1.0, 1.0, -1.0) setup - so your view frustum will lie half behind the camera (which is perfectly fine for ortho projections, but might seem counterintuitive). For the camera orientation, that part is a bit more ambigous. Usually, GL had the convention that the camera looks into the -z direction, but in clip space, +z will point into the screen, and the classic Ortho and Perspective functions treat this by actually using z_near=-near and z_far=-far for the near and far parameters. (That is also is also the reason why identy transform is achieved through that Ortho call with the last two signs flipped relative to the x and y ranges). So in that case, one could argue that the camera is actually looking along +z, or one could argue that the camera looks along -z, but the near and far planes are swapped by the projection. That is a matter of how you like to interpret these things. These conventions mostly matter to classic "fixed-function" GL, which uses the eye position for lighting and fog calculations (and maybe a view things else). And it also might assume the "camera looks along -z" convention for calculation of the specular lighting term if GL_LIGHT_MODEL_LOCAL_VIEWER is not enabled (which is disabled by default, see glLightModel().

In modern GL, no such conventions exist besides the left-handedness of the clip space, and you can make your own conventions for an eye space (if you need one).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!