Render to QOpenGLFramebufferObject GL_HALF_FLOAT

I want to render to a half float texture using QOpenGLFramebufferObject. I try to create the fbo with the following code:

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

But when I run the program this message appears in the console:

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

If I use GL_RGBA instead of GL_HALF_FLOAT the error message doesn't appear, but this doesn't fit my purpose.

How can I render to a half float texture using QT?

Upvotes: 1

Views: 716

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 474216

By providing an actual OpenGL image format. GL_HALF_FLOAT is not an image format; it's an enum that represents a type. You can use that as the type in pixel transfer operations, but that's not an image format.

An image format that uses 16-bit floats would be GL_RGBA16F.

Upvotes: 3

Related Questions