OpenGL 缓冲区如何实现?程序运行之间状态持续吗?

发布于 2024-10-01 02:20:35 字数 277 浏览 0 评论 0原文

我正在编写一个OpenGL程序,该程序绘制到辅助缓冲区中,然后辅助缓冲区的内容被累积到累积缓冲区中,然后再被GL_RETURN-ed到后缓冲区(本质上是合成到屏幕上)。简而言之,我正在做一种运动模糊。然而奇怪的是,当我重新编译并重新运行程序时,我看到了先前程序运行的辅助/累积缓冲区的内容。这没有道理。我是否误解了什么,程序重新启动时OpenGL的状态不应该完全重置吗?

我正在 GeForce Go 6150 上的 Gentoo Linux nVidia 驱动程序 195.36.31 中编写 SDL/OpenGL 程序。

I'm writing an OpenGL program that draws into an Auxiliary Buffer, then the content of the Auxiliary Buffer is accumulated to the Accumulation Buffer before being GL_RETURN-ed to the Back buffer (essentially to be composited to the screen). In short, I'm doing sort of a motion blur. However the strange thing is, when I recompile and rerun my program, I was seeing the content of the Auxiliary/Accumulation Buffer from the previous program runs. This does not make sense. Am I misunderstanding something, shouldn't OpenGL's state be completely reset when the program restarts?

I'm writing an SDL/OpenGL program in Gentoo Linux nVidia Drivers 195.36.31 on GeForce Go 6150.

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

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

发布评论

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

评论(2

我的影子我的梦 2024-10-08 02:20:35

不 - 您的 GPU 没有理由清除其内存。您有责任在使用纹理之前清除(或初始化)它们。

No - there's no reason for your GPU to ever clear its memory. It's your responsibility to clear out (or initialize) your textures before using them.

差↓一点笑了 2024-10-08 02:20:35

实际上,OpenGL 状态被初始化为明确定义的值。

然而,GL 状态由所有二进制开关 (glEnable)、混合、深度测试模式等设置组成。每个设置都有其默认设置,在 OpenGL 规范,您可以确定它们将在上下文创建时强制执行。

关键是,帧缓冲区(或纹理数据或顶点缓冲区或任何东西)不是所谓的“GL 状态”的一部分。 GL 状态“存在”于您的驱动程序中。存储在 GPU 内存中的内容是完全不同的东西,并且在您要求驱动程序(通过 GL 调用)对其进行初始化之前,它是未初始化的。因此,如果您在启动时没有清除或初始化它,则完全有可能在纹理内存中什至在帧缓冲区本身中保留先前运行的剩余部分。

Actually, the OpenGL state is initialized to well-defined values.

However, the GL state consists of settings like all binary switches (glEnable), blending, depth test mode... etc, etc. Each of those has its default settings, which are described in OpenGL specs and you can be sure that they will be enforced upon context creation.

The point is, the framebuffer (or texture data or vertex buffers or anything) is NOT a part of what is called "GL state". GL state "exists" in your driver. What is stored in the GPU memory is totally different thing and it is uninitialized until you ask the driver (via GL calls) to initialize it. So it's completely possible to have the remains of previous run in texture memory or even in the frame buffer itself if you don't clear or initialize it at startup.

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