How to show FBO contents in a QGLWidget?
-
I basically tried it this way:
class Foo : public QGLWidget { public: Foo( QWidget* parent ) : QGLWidget( parent ) { } void paintGL() override { QOpenGLFramebufferObject fbo( size( ) ); fbo.bind( ); glClearColor( 1.0f, 0.0f, 0.0f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); fbo.release( ); bindTexture( fbo.toImage( ), fbo.format( ).textureTarget( ), fbo.format( ).internalTextureFormat( ) ); drawTexture( rect( ), fbo.texture( ), fbo.format( ).textureTarget( ) ); } };
but the widget will just show a black background then. I've also tried to bind the fbo texture and draw a quad - same result. If I uncomment the fbo code and draw directly to the GLWidget it works as expected. Any hints about what I'm doing wrong here?