Re: FBO with GLCanvas
Posted by Sven Gothel on Nov 29, 2019; 9:38pm
URL: https://forum.jogamp.org/FBO-with-GLCanvas-tp4040147p4040154.html
I was just glancing over this post
and wanted to add some thoughts here.
On 11/28/19 12:47 PM, Bob [via jogamp] wrote:
> - do not take into account the error. glReadBuffer ends with an error because
> getDefaultReadBuffer() is GL_BACK but when a FBO is bound, only
> GL_COLOR_ATTACHMENTi is allowed. However at this point, glGet(GL_READ_BUFFER)
> is GL_COLOR_ATTACHMENT0 so the following glReadPixels reads the correct buffer.
> It is not really clean but this works.
That is the normal expected behavior,
using the proper read buffer.
For example GLFBODrawable's implementation
overrides GLDrawable methods used in GLContext (and GL)
to retrieve the proper values of the buffers - see below.
This is part of our 'managed code' convenience
to have same behavior exposed whether you use onscreen
or offscreen GLDrawable instances.
<<-------------
abstract int getDefaultDrawFramebuffer()
Return the default draw framebuffer name.
abstract int getDefaultPixelDataFormat()
Get the default pixel data format, as required by e.g.
abstract int getDefaultPixelDataType()
Get the default pixel data type, as required by e.g.
abstract int getDefaultReadBuffer()
Returns the default color buffer within the current bound
getDefaultReadFramebuffer(), i.e.
abstract int getDefaultReadFramebuffer()
Return the default read framebuffer name.
----------------->>>
GLFBODrawable is the offscreen case using
default construction of drawable/context and operating
with our GLEventListener model, like via GLWindow.
It then just uses FBObject's buffer name getter
to get the right read/write buffer names:
<<<-------
/** Returns the framebuffer name to render to. */
public final int getWriteFramebuffer() { return fbName; }
/** Returns the framebuffer name to read from. Depending on multisampling,
this may be a different framebuffer. */
public final int getReadFramebuffer() {
return 0 < samples ? ( null != samplingSink ?
samplingSink.getReadFramebuffer() : 0 ) : fbName;
}
public final int getDefaultReadBuffer() { return GL.GL_COLOR_ATTACHMENT0; }
-------------->>>>
and so on and so forth.
Cheers, Sven