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

    2. 3D 应用程序中的 OpenGL 2D hud

      时间:2023-09-17
            • <bdo id='yYtjb'></bdo><ul id='yYtjb'></ul>

                <tbody id='yYtjb'></tbody>

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

                <legend id='yYtjb'><style id='yYtjb'><dir id='yYtjb'><q id='yYtjb'></q></dir></style></legend>
                <i id='yYtjb'><tr id='yYtjb'><dt id='yYtjb'><q id='yYtjb'><span id='yYtjb'><b id='yYtjb'><form id='yYtjb'><ins id='yYtjb'></ins><ul id='yYtjb'></ul><sub id='yYtjb'></sub></form><legend id='yYtjb'></legend><bdo id='yYtjb'><pre id='yYtjb'><center id='yYtjb'></center></pre></bdo></b><th id='yYtjb'></th></span></q></dt></tr></i><div id='yYtjb'><tfoot id='yYtjb'></tfoot><dl id='yYtjb'><fieldset id='yYtjb'></fieldset></dl></div>
                <tfoot id='yYtjb'></tfoot>
                本文介绍了3D 应用程序中的 OpenGL 2D hud的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我一直在尝试在我的 OpenGL 应用程序中创建一个平视显示器.环顾四周,似乎使用正射投影的方法是这样做的,但到目前为止,我还无法使程序正确呈现.发生的事情不是在我的显示器顶部渲染,而是出现奇怪的图形故障,如下所示:

                I have been trying to create a hud in my OpenGL application. Having looked around, it seems the way to do it is with an ortho projection, but so far I have not been able to get the program to render correctly. What is happening is instead of rendering on top of my display, I'm getting odd graphical glitches as seen here:

                如果我注释掉 hud 代码,一切都会完美呈现.

                If I comment out the hud code, everything renders perfectly.

                glEnable(GL_DEPTH_TEST);
                glDepthFunc(GL_LESS);
                
                //Set up projection matrix
                glMatrixMode(GL_PROJECTION);
                glLoadIdentity();
                //Using gluPerspective. It's pretty easy and looks nice.
                gluPerspective(fov, aspect, zNear, zFar);
                
                //Set up modelview matrix
                glMatrixMode(GL_MODELVIEW);
                glLoadIdentity();
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                
                //3D rendering
                
                glDepthMask(GL_FALSE);
                glDisable(GL_DEPTH_TEST);
                
                glMatrixMode(GL_PROJECTION);
                glLoadIdentity();
                gluOrtho2D(0,window_width,0,window_height); //left,right,bottom,top
                
                glMatrixMode(GL_MODELVIEW);
                glLoadIdentity();
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                
                glColor3f(0.0,0.0,1.0);
                glBegin(GL_QUADS);
                    glVertex2f(50,50);
                    glVertex2f(50,100);
                    glVertex2f(100,100);
                    glVertex2f(100,50);
                glEnd();
                

                推荐答案

                渲染完 HUD 后,您需要重新启用深度写入

                Once you're done rendering the HUD, you need to re-enable the depth writes

                glDepthMask(GL_TRUE);
                

                这篇关于3D 应用程序中的 OpenGL 2D hud的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:最小无窗口 OpenGL 上下文初始化 下一篇:OpenGL围绕一条线旋转对象

                相关文章

                最新文章

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

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