framebuffer - OpenGL DSA 和 FBO

标签 framebuffer opengl-4

我升级了 FBO 代码以使用 OpenGL 4.5 中的 DSA(直接访问状态)功能。

一切都很好,但在绘制之前我仍然需要使用 glBindFramebuffer() 。有什么我错过的吗?

在向我的 FBO 提款之前,我正在考虑这个电话。

glNamedFramebufferDrawBuffer(m_FBO, GL_COLOR_ATTACHMENT0);

然后使用这个恢复到默认帧缓冲区。

glDrawBuffer(GL_BACK);

但是这不起作用。我还应该使用 glBindFramebuffer() 吗?最后,如果是的话,glNamedFramebufferDrawBuffer() 有什么用?

我几乎找不到关于此的明确主题。

最佳答案

glNamedFramebufferDrawBuffer不将帧缓冲区绑定(bind)到目标。它仅指定命名帧缓冲区对象的颜色缓冲区。

参见OpenGL 4.6 core profile specification - 17.4.1 Selecting Buffers for Writing, p. 513 :

17.4.1 Selecting Buffers for Writing

The first such operation is controlling the color buffers into which each of the fragment color values is written. This is accomplished with either DrawBuffer or DrawBuffers commands described below. The set of buffers of a framebuffer object to which fragment color zero is written is controlled with the commands

void DrawBuffer( enum buf );
void NamedFramebufferDrawBuffer( uint framebuffer, enum buf );

For DrawBuffer, the framebuffer object is that bound to the DRAW_FRAMEBUFFER binding. For NamedFramebufferDrawBuffer, framebuffer is zero or the name of a framebuffer object. If framebuffer is zero, then the default draw framebuffer is affected.

参见OpenGL 4.6 core profile specification - 9.2 Binding and Managing Framebuffer Objects, p. 297 :

A framebuffer object is created by binding a name returned by GenFramebuffers (see below) to DRAW_FRAMEBUFFER or READ_FRAMEBUFFER. The binding is effected by calling

void BindFramebuffer( enum target, uint framebuffer );

将目标设置为所需的帧缓冲区目标,将帧缓冲区设置为帧缓冲区对象名称。生成的帧缓冲区对象是一个新的状态向量...

关于framebuffer - OpenGL DSA 和 FBO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48140060/

相关文章:

opengl - 设置 OpenGL 多个渲染目标

python - OpenGL 中的透明 FrameBuffer 背景

opengl - glMultiDrawElementsIndirect 很慢

javascript - WebGL:在带有深度模板纹理附件的帧缓冲区上未清除颜色

opengl - 使用 Cg 的 OpenGL 中的多个渲染目标

OpenGL 渲染到透明纹理

c++ - OpenGL 4.5 : glClear() doesn't work (using SDL2 and GLEW)

c - 如何在考虑性能的情况下最好地用C编写体素引擎

c++ - OpenGL SuperBible 第 6 版,缺少头文件 sb6.h

glsl - imageAtomic GLSL 函数和 RGBA 图像格式