As we transition to Discourse, this is a response in reply to this post made in the old Zoho forum.
Although I’m not familiar with WebGL, I think you are right about
preserveDrawingBuffer. If it is true, you don’t call
gl::clear, otherwise you do.
About creating an
gl::Fbo without alpha, there are many ways to do this:
gl::Fbo::create( int width, int height, bool alpha, bool depth, bool stencil) method
gl::Fbo::Format fboFormat; fboFormat.colorTexture( gl::Fbo::Format::getDefaultColorTextureFormat( false ) ); mFbo = gl::Fbo::create( width, height, fboFormat );
or you cen set the color texture internal format
gl::Texture2d::Format colorTextureFormat; colorTextureFormat.internalFormat( GL_RGB ); gl::Fbo::Format fboFormat; fboFormat.colorTexture( colorTextureFormat ); mFbo = gl::Fbo::create( width, height, fboFormat );
Thanks a lot for transitioning the post to the new system and answering
Makes sense I’ll try that. I can see how that will work to customize an Fbo I create myself but is there a way to customize the Fbo that is “automatically” created for the final drawing to screen? Or do I have to create my own customized, draw the final scene into it, and then use that Fbo for the final drawing to screen?
Thanks so much!
On desktop platforms the screen buffer generally isn’t an FBO (though it is on some mobile platforms, like iOS). As such, it doesn’t meaningfully have alpha regardless, since it is never blended into another drawing buffer.
If you want to draw without alpha blending, you can disable blending:
… // draw opaque things
For a long time, alpha was disabled by default in Cinder. Recent versions switched to having alpha enabled by default with the aim of making it more accessible to new users.
You can use the DST_ALPHA in a blend equation, giving purpose to the destination buffer’s alpha channel, but I don’t know what use cases it has. The common factors are
(1.0, 1.0 - source_alpha) for premultiplied alpha, and
(source_alpha, 1.0 - source_alpha) for non-premultiplied alpha.