<tfoot id='SjwKW'></tfoot>
      <bdo id='SjwKW'></bdo><ul id='SjwKW'></ul>

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

      <legend id='SjwKW'><style id='SjwKW'><dir id='SjwKW'><q id='SjwKW'></q></dir></style></legend>
    1. <i id='SjwKW'><tr id='SjwKW'><dt id='SjwKW'><q id='SjwKW'><span id='SjwKW'><b id='SjwKW'><form id='SjwKW'><ins id='SjwKW'></ins><ul id='SjwKW'></ul><sub id='SjwKW'></sub></form><legend id='SjwKW'></legend><bdo id='SjwKW'><pre id='SjwKW'><center id='SjwKW'></center></pre></bdo></b><th id='SjwKW'></th></span></q></dt></tr></i><div id='SjwKW'><tfoot id='SjwKW'></tfoot><dl id='SjwKW'><fieldset id='SjwKW'></fieldset></dl></div>
      1. Opengl:3D 上的 2d HUD

        时间:2023-09-18
              <tbody id='airku'></tbody>

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

                <legend id='airku'><style id='airku'><dir id='airku'><q id='airku'></q></dir></style></legend>

                  <tfoot id='airku'></tfoot>

                1. <small id='airku'></small><noframes id='airku'>

                  本文介绍了Opengl:3D 上的 2d HUD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我查看了此处发布的一些关于此事的问题,但仍然无法弄清楚为什么我的 2d HUD 出现但使我的 3d 渲染世界消失.

                  I have looked at some questions posted here on the matter and still cant work out why my 2d HUD appears but makes my 3d Rendered world disappear.

                  似乎 2d 场景正在控制整个屏幕,所以我不时可以看到 3d 场景在 2d 场景中出现故障.因此,即使我只需要渲染一个 10 x 10 像素的四边形,它也会渲染它然后将屏幕的其余部分空白.

                  It seems that the 2d scene is taking control of the entire screen so every now and then I can see the 3d scene glitching through the 2d scene. So even though I its only ment to be rendering a quad thats 10 x 10 pixels it renders this then blanks out the rest of the screen.

                  glMatrixMode(GL_PROJECTION);
                  glLoadIdentity();
                  gluPerspective(40.0,(GLdouble)x/(GLdouble)y,0.5,20.0);
                  glMatrixMode(GL_MODELVIEW);
                  glViewport(0,0,x,y);
                  glClear(GL_COLOR_BUFFER_BIT);
                  glLoadIdentity();
                  glTranslatef(0.0,-0.5,-6.0);
                  
                  glPushMatrix();
                  
                  ..Draw some 3d stuff...
                  
                  glPopMatrix();
                  // Start 2d
                  glMatrixMode(GL_PROJECTION);
                  glLoadIdentity();
                  glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1, 1);
                  
                  glMatrixMode(GL_MODELVIEW);
                  glLoadIdentity();
                  glColor3f(0.0f, 255.0f, 1.0f);
                  glBegin(GL_QUADS);
                      glVertex2f(0.0, 0.0);
                      glVertex2f(10.0, 0.0);
                      glVertex2f(10.0, 10.0);
                      glVertex2f(0.0, 10.0);
                  glEnd();
                  

                  然后我交换缓冲区

                  这是我的代码顺序.就像它先生成 3d 空间然后生成 2d 空间,然后又抵消了 3d 空间.

                  Here is the order of my code. Its like it makes the 3d space then makes the 2d space which in turn cancels out the 3d space.

                  推荐答案

                  花了一点时间才弄明白,以防万一其他人有同样的问题:

                  Took a little while to figure it out, so just in case others have the same issues:

                      ...After Drawing 3d Stuff...
                  
                  glMatrixMode(GL_PROJECTION);
                  glPushMatrix();
                  glLoadIdentity();
                  glOrtho(0.0, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0, -1.0, 10.0);
                  glMatrixMode(GL_MODELVIEW);
                  //glPushMatrix();        ----Not sure if I need this
                  glLoadIdentity();
                  glDisable(GL_CULL_FACE);
                  
                  glClear(GL_DEPTH_BUFFER_BIT);
                  
                  glBegin(GL_QUADS);
                      glColor3f(1.0f, 0.0f, 0.0);
                      glVertex2f(0.0, 0.0);
                      glVertex2f(10.0, 0.0);
                      glVertex2f(10.0, 10.0);
                      glVertex2f(0.0, 10.0);
                  glEnd();
                  
                  // Making sure we can render 3d again
                  glMatrixMode(GL_PROJECTION);
                  glPopMatrix();
                  glMatrixMode(GL_MODELVIEW);
                  //glPopMatrix();        ----and this?
                  
                  ...Then swap buffers...
                  

                  :)

                  这篇关于Opengl:3D 上的 2d HUD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:错误 LNK2019:函数 ___tmainCRTStartup 中引用了未解析的 下一篇:强制机器使用专用显卡?

                  相关文章

                  最新文章

                  1. <legend id='nGNCt'><style id='nGNCt'><dir id='nGNCt'><q id='nGNCt'></q></dir></style></legend>

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

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

                      • <bdo id='nGNCt'></bdo><ul id='nGNCt'></ul>
                      <tfoot id='nGNCt'></tfoot>