使用 OpenGL 实现 Z 缓冲区

发布于 2024-09-30 20:30:29 字数 326 浏览 1 评论 0原文

对于一个项目,我想实现我自己的 Z 缓冲区。我知道算法以及如何实现它。因为我不想编写整个图形引擎,所以我计划使用 OpenGL,问题是,如何将我自己的算法与 openGL 结合起来?

我在某处读到,我可以自己计算所有内容,然后将每个像素的数据传递给 GLDrawPixels() ,但这似乎有点矫枉过正。重点是我不想实现三角测量算法等。

我的目标是使用openGL直到线框,然后使用我自己的z缓冲区算法,然后再次使用openGL绘制最终图片。 (对于我的项目,z 缓冲区是唯一重要的,包括光和阴影)。有没有办法可以做到这一点,或者我必须自己实现一切并让 openGL 绘制最终结果?

真挚地

For a project I want to implement my own Z-buffer. I know the algorithm and how to implement this. Because I do not want to write an entire graphics engine I was planning on using OpenGL, the problem is, how can I combine my own algorithm with openGL?

I read somewhere that I could calculate everything myself and then pass the data per pixel to GLDrawPixels() but that seems a bit overkill. The point is that I don't want to implement triangulation algorithms etc..

My goal is to use openGL up until the wireframe, then use my own z-buffer algorithm and then use openGL again to draw the final picture. (for my project, the z-buffer is the only thing that matters, including light and shadows that is). Is there a way this can be done or do I have to implement everything myself and let openGL just draw the endresult?

Sincerely

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄居人 2024-10-07 20:30:29

您可以通过“手动”计算顶点距离来将要绘制的顶点的颜色设置为其 z 值。但我认为可以将 z 缓冲区绑定为纹理,然后绘制一个带有 z 缓冲区纹理的大四边形覆盖屏幕。

You could set the colour of the vertices you are drawing to their z-values by calculating their distance 'manually'. But I think it's possible to bind the z-buffer as a texture and then draw a large quad covering with screen with the z-buffer texture on it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文