• <bdo id='9Dng6'></bdo><ul id='9Dng6'></ul>
  • <tfoot id='9Dng6'></tfoot>
  • <legend id='9Dng6'><style id='9Dng6'><dir id='9Dng6'><q id='9Dng6'></q></dir></style></legend>
  • <small id='9Dng6'></small><noframes id='9Dng6'>

  • <i id='9Dng6'><tr id='9Dng6'><dt id='9Dng6'><q id='9Dng6'><span id='9Dng6'><b id='9Dng6'><form id='9Dng6'><ins id='9Dng6'></ins><ul id='9Dng6'></ul><sub id='9Dng6'></sub></form><legend id='9Dng6'></legend><bdo id='9Dng6'><pre id='9Dng6'><center id='9Dng6'></center></pre></bdo></b><th id='9Dng6'></th></span></q></dt></tr></i><div id='9Dng6'><tfoot id='9Dng6'></tfoot><dl id='9Dng6'><fieldset id='9Dng6'></fieldset></dl></div>

        如何在 OpenGL 中使用 glOrtho()?

        时间:2023-09-18
          <bdo id='0lAcg'></bdo><ul id='0lAcg'></ul>
              <tbody id='0lAcg'></tbody>
              <i id='0lAcg'><tr id='0lAcg'><dt id='0lAcg'><q id='0lAcg'><span id='0lAcg'><b id='0lAcg'><form id='0lAcg'><ins id='0lAcg'></ins><ul id='0lAcg'></ul><sub id='0lAcg'></sub></form><legend id='0lAcg'></legend><bdo id='0lAcg'><pre id='0lAcg'><center id='0lAcg'></center></pre></bdo></b><th id='0lAcg'></th></span></q></dt></tr></i><div id='0lAcg'><tfoot id='0lAcg'></tfoot><dl id='0lAcg'><fieldset id='0lAcg'></fieldset></dl></div>

              • <small id='0lAcg'></small><noframes id='0lAcg'>

                  <tfoot id='0lAcg'></tfoot>
                  <legend id='0lAcg'><style id='0lAcg'><dir id='0lAcg'><q id='0lAcg'></q></dir></style></legend>
                  本文介绍了如何在 OpenGL 中使用 glOrtho()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我无法理解 glOrtho 的用法.有人可以解释一下它的用途吗?

                  I can't understand the usage of glOrtho. Can someone explain what it is used for?

                  是用来设置x y 和z 坐标范围限制的吗?

                  Is it used to set the range of x y and z coordinates limit?

                  glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
                  

                  表示x、y、z的范围是-1到1?

                  It means that the x, y and z range is from -1 to 1?

                  推荐答案

                  看看这张图:

                  glOrtho 命令生成一个倾斜"投影,您可以在底行看到.无论顶点在 z 方向上有多远,它们都不会后退.

                  The glOrtho command produces an "Oblique" projection that you see in the bottom row. No matter how far away vertexes are in the z direction, they will not recede into the distance.

                  每次我需要在 OpenGL 中制作 2D 图形(例如健康栏、菜单等)时,我都会使用 glOrtho每次调整窗口大小时都使用以下代码:

                  I use glOrtho every time I need to do 2D graphics in OpenGL (such as health bars, menus etc) using the following code every time the window is resized:

                  glMatrixMode(GL_PROJECTION);
                  glLoadIdentity();
                  glOrtho(0.0f, windowWidth, windowHeight, 0.0f, 0.0f, 1.0f);
                  

                  这会将 OpenGL 坐标重新映射到等效的像素值(X 从 0 到 windowWidth 和 Y 从 0 到 windowHeight).请注意,我翻转了 Y 值,因为 OpenGL 坐标从窗口的左下角开始.所以通过翻转,我得到了一个更传统的 (0,0),而不是从窗口的左上角开始.

                  This will remap the OpenGL coordinates into the equivalent pixel values (X going from 0 to windowWidth and Y going from 0 to windowHeight). Note that I've flipped the Y values because OpenGL coordinates start from the bottom left corner of the window. So by flipping, I get a more conventional (0,0) starting at the top left corner of the window rather.

                  请注意,Z 值是从 0 到 1 裁剪的.因此,当您为顶点位置指定 Z 值时要小心,如果它落在该范围之外,它将被裁剪.否则,如果它在该范围内,除了 Z 测试之外,它似乎对位置没有影响.

                  Note that the Z values are clipped from 0 to 1. So be careful when you specify a Z value for your vertex's position, it will be clipped if it falls outside that range. Otherwise if it's inside that range, it will appear to have no effect on the position except for Z tests.

                  这篇关于如何在 OpenGL 中使用 glOrtho()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何根据 Wavefront (.obj) 文件中给出的纹理索引对 下一篇:如何仅使用 OpenGL 方法绘制文本?

                  相关文章

                  最新文章

                • <legend id='VO74G'><style id='VO74G'><dir id='VO74G'><q id='VO74G'></q></dir></style></legend>

                    <small id='VO74G'></small><noframes id='VO74G'>

                    • <bdo id='VO74G'></bdo><ul id='VO74G'></ul>
                    <i id='VO74G'><tr id='VO74G'><dt id='VO74G'><q id='VO74G'><span id='VO74G'><b id='VO74G'><form id='VO74G'><ins id='VO74G'></ins><ul id='VO74G'></ul><sub id='VO74G'></sub></form><legend id='VO74G'></legend><bdo id='VO74G'><pre id='VO74G'><center id='VO74G'></center></pre></bdo></b><th id='VO74G'></th></span></q></dt></tr></i><div id='VO74G'><tfoot id='VO74G'></tfoot><dl id='VO74G'><fieldset id='VO74G'></fieldset></dl></div>
                  1. <tfoot id='VO74G'></tfoot>