渲染到 QOpenGLFramebufferObject GL_HALF_FLOAT

Render to QOpenGLFramebufferObject GL_HALF_FLOAT

我想使用 QOpenGLFramebufferObject 渲染为半浮点纹理。 我尝试使用以下代码创建 fbo:

structureTensorTexture = new QOpenGLFramebufferObject(
    renderWidth,
    renderHeight,
    QOpenGLFramebufferObject::NoAttachment,
    GL_TEXTURE_2D,
    GL_HALF_FLOAT
);

但是当我 运行 程序在控制台中出现此消息时:

[opengl\qopenglframebufferobject.cpp line 544] OpenGL Error: 1280
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete, missing attachment.

如果我使用 GL_RGBA 而不是 GL_HALF_FLOAT,则不会出现错误消息,但这不符合我的目的。

如何使用 QT 渲染半浮点纹理?

通过提供实际的 OpenGL 图像格式。 GL_HALF_FLOAT 不是 图片格式 ;它是一个代表类型的枚举。您可以将其用作 type in pixel transfer operations,但这不是图像格式。

使用 16 位浮点数的 image format 将是 GL_RGBA16F