c/c++语言开发共享Pre Z缓冲区通过OpenGL?

我怎样才能使用openGL进行Z缓冲预处理。

我试过这个:

glcolormask(0,0,0,0); //disable color buffer //draw scene glcolormask(1,1,1,1); //reenable color buffer //draw scene //flip buffers 

但它不起作用。 这样做后我什么也没看到。 有什么更好的方法呢?

谢谢

     // clear everything glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // z-prepass glEnable(GL_DEPTH_TEST); // We want depth test ! glDepthFunc(GL_LESS); // We want to get the nearest pixels glcolormask(0,0,0,0); // Disable color, it's useless, we only want depth. glDepthMask(GL_TRUE); // Ask z writing draw() // real render glEnable(GL_DEPTH_TEST); // We still want depth test glDepthFunc(GL_LEQUAL); // EQUAL should work, too. (Only draw pixels if they are the closest ones) glcolormask(1,1,1,1); // We want color this time glDepthMask(GL_FALSE); // Writing the z component is useless now, we already have it draw(); 

    你正在使用glColorMask做正确的事情。

    但是,如果你没有看到任何东西,可能是因为你使用了错误的深度测试function。 你需要GL_LEQUAL,而不是GL_LESS(这恰好是默认值)。

     glDepthFunc(GL_LEQUAL); 

    如果我找到你,你试图禁用OpenGL执行的深度测试来确定剔除。 你在这里使用的是颜色function,这对我来说没有意义。 我想你正在努力做到以下几点:

     glDisable(GL_DEPTH_TEST); // disable z-buffer // draw scene glEnable(GL_DEPTH_TEST); // enable z-buffer // draw scene // flip buffers 

    不要忘记在每次通过开始时清除深度缓冲区。

      以上就是c/c++开发分享Pre Z缓冲区通过OpenGL?相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/c-cdevelopment/560559.html

      (0)
      上一篇 2021年1月28日
      下一篇 2021年1月28日

      精彩推荐