I need to render to a framebufferobject with GL_FLOAT as internal format for floating-point computations. I know how to achieve this using native OpenGL calls, such as:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height,
0, GL_RGBA, GL_FLOAT, NULL);
In order to use QPainter to render to a FBO, QGLFramebufferObject is required. However, QGLFramebufferObject doesn't allow to set the type, only the internal format and format of the texture (that is used in an color-attachment in my case).
Is there any way of using floating-point precision with QGLFramebufferObject in Qt 4.8?
I know I could somehow patch and recompile Qt, but that's cumbersome and not very elegant. I also considered writing my own FramebufferObject class, but then one has to derive from QPaintDevice and with that provide a custom QPaintEngine. Not a good solution, as Qt obviously has a paintengine for that, but it's not accessible.
The internal format is the only thing that makes a texture floating-point. For example:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height,
0, GL_RGBA, GL_FLOAT, NULL);
This is not a floating-point texture. It is a 8-bit-per-component unsigned normalized texture. Because that's what GL_RGBA8
means.
So just set the internal format of the QGLFramebufferObject
to be one of the available floating-point formats.