Keeping a square clipping volume square, regardless of viewport size in opengl? -
I'm working through the OpenGL Superbib 4 version. If the viewport matches the dimensions of the window but matches the dimensions of the window, then a description of that window is mentioned, but it is mapped to a clipping volume, this image is distorted (long and thin viewport Like)
The solution to keep the image class is the following code:
// Install clipping volume (left, right, bottom, top, near, far) aspectRatio = (GL Float ) W / (GL Float) H; If (w <= h) is a glotho (-100.0, 100.0, -100 / aspect ratio, 100.0 / aspect ratio, 1.0, -1.0); Other one glotho (-100.0 * side layer, 100.0 * aspect ratio, -100.0, 100.0, 1.0, -1.0); An explanation has been given for this code, but I can not understand it. Why are we increasing the height of clipping according to Aspect RITIO?
Two aspect ratios in OpenGLL that you need to be aware of: < Ol>
Aspect ratio of viewport , which is specified when you call glViewport See disappointment aspect ratio, which is specified through your projection change, whether it is cipher (e.g., defined by glOrtho ), or perspective glFrustum , or gluPerspective most often). Now, to provide intersections as intersections, two aspect ratios are needed to match when you change the size of a window, then you will see the aspect ratio of the viewport Set to glViewport (0, 0, width, height) with the call; The projection change is either clear to specify the aspect ratio, such as when you call gluPerspective , the aspect ratio of despair to see its second parameter However, for calls like glOrtho , or glFrustum , the aspect ratio of the frustration of seeing is controlled at the width and height of the volume of view. Viewing the context in which you mention (and the same thing works for the projections of perspective), here the width of the view right - left , similarly, height above Below , and the ratio of those two quantities to the ratio of the aspect ratio is the aspect ratio. Now, remember that we need two aspect ratios for the match. It is not possible that we can modify the viewport, because it usually happens that you want to use all the pixels in the window, or there is no risk to the risk of the objects, so we can see the view To match the aspect ratio of the volume are forced to modify. We do this by modifying the width or the height of the viewing volume based on the aspect ratio of the viewport, which appears in the code you provided. Specifically, if the aspect ratio of the viewport is more than 1.0 (i.e., longer than that), then we need to broaden our view volumes, which is why we have left and right By the aspect ratio, if the aspect of the viewport is less than 1.0, then we should make the viewing volume taller. In this case, we use reciprocal of aspect ratios (which will be larger than 1.0), provide appropriate scaling for top and down .
Comments
Post a Comment