Interface GLFBODrawable
-
- All Superinterfaces:
GLDrawable,NativeSurfaceHolder
- All Known Subinterfaces:
GLFBODrawable.Resizeable,GLOffscreenAutoDrawable.FBO
public interface GLFBODrawable extends GLDrawable
Platform-independentGLDrawablespecialization, exposingFBObjectfunctionality.A
GLFBODrawableis uninitialized until aGLContextis bound and made current the first time, hence only then it's capabilities fully reflect expectations, i.e. color, depth, stencil and MSAA bits will be valid only after the firstmakeCurrent()call. On-/offscreen bits are valid aftersetRealized(true).MSAA is used if
requested.Double buffering is used if
requested.In MSAA mode, it always uses the implicit 2nd
framebuffersink. Hence double buffering is always the case w/ MSAA.In non MSAA a second explicit
framebufferis being used. This method allows compliance w/ the spec, i.e. read and draw framebuffer selection and double buffer usage for e.g.glReadPixels(..). This method also allows usage of both textures seperately.It would be possible to implement double buffering simply using
FBObject.Colorbuffers with oneframebuffer. This would require mode selection and hence complicate the API. Besides, it would not support differentiation of read and write framebuffer and hence not be spec compliant.Actual swapping of the
FBObject.Colorbuffers and/orframebufferis performed either in thecontext current hookor whenswapping buffers, whatever comes first.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceGLFBODrawable.ResizeableResizeableGLFBODrawablespecialization
-
Field Summary
Fields Modifier and Type Field Description static intFBOMODE_USE_TEXTURE
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description FBObject.ColorbuffergetColorbuffer(int bufferName)Returns the namedFBObject.Colorbufferinstance.FBObjectgetFBObject(int bufferName)If MSAA is being used andGL.GL_FRONTis requested, the internalFBObjectsample sinkis being returned.intgetFBOMode()intgetNumBuffers()intgetNumSamples()intgetTextureUnit()booleanisInitialized()voidresetSize(GL gl)Notify this instance about upstream size change to reconfigure theFBObject.voidsetFBOMode(int modeBits)Set the FBO mode bits used for FBO creation.intsetNumBuffers(int bufferCount)Sets the number of buffers (FBO) being used if usingdouble buffering.voidsetNumSamples(GL gl, int newSamples)Set the number of sample buffers if using MSAAvoidsetTextureUnit(int unit)-
Methods inherited from interface com.jogamp.opengl.GLDrawable
createContext, getChosenGLCapabilities, getFactory, getGLProfile, getHandle, getNativeSurface, getRequestedGLCapabilities, getSurfaceHeight, getSurfaceWidth, isGLOriented, isRealized, setRealized, swapBuffers, toString
-
-
-
-
Field Detail
-
FBOMODE_USE_TEXTURE
static final int FBOMODE_USE_TEXTURE
- See Also:
- Constant Field Values
-
-
Method Detail
-
isInitialized
boolean isInitialized()
- Returns:
trueif initialized, i.e. aGLContextis bound and made current once, otherwisefalse.
-
setFBOMode
void setFBOMode(int modeBits) throws IllegalStateExceptionSet the FBO mode bits used for FBO creation.Default value is:
FBOMODE_USE_TEXTURE.If
GLRendererQuirks.BuggyColorRenderbufferis set,FBOMODE_USE_TEXTUREis always added at initialization.- Parameters:
modeBits- custom FBO mode bits likeFBOMODE_USE_TEXTURE.- Throws:
IllegalStateException- if already initialized, seeisInitialized().
-
getFBOMode
int getFBOMode()
- Returns:
- the used FBO mode bits, mutable via
setFBOMode(int)
-
resetSize
void resetSize(GL gl) throws GLException
Notify this instance about upstream size change to reconfigure theFBObject.- Parameters:
gl- GL context object bound to this drawable, will be made current during operation. A prev. current context will be make current after operation.- Throws:
GLException- if resize operation failed
-
getTextureUnit
int getTextureUnit()
- Returns:
- the used texture unit
-
setTextureUnit
void setTextureUnit(int unit)
- Parameters:
unit- the texture unit to be used
-
setNumSamples
void setNumSamples(GL gl, int newSamples) throws GLException
Set the number of sample buffers if using MSAA- Parameters:
gl- GL context object bound to this drawable, will be made current during operation. A prev. current context will be make current after operation.newSamples- new sample size- Throws:
GLException- if resetting the FBO failed
-
getNumSamples
int getNumSamples()
- Returns:
- the number of sample buffers if using MSAA, otherwise 0
-
setNumBuffers
int setNumBuffers(int bufferCount) throws IllegalStateException, GLExceptionSets the number of buffers (FBO) being used if usingdouble buffering.If
double bufferingis not chosen, this is a NOP.Must be called before
initialization, otherwise an exception is thrown.- Returns:
- the new number of buffers (FBO) used, maybe different than the requested
bufferCount(see above) - Throws:
IllegalStateException- if already initialized, seeisInitialized().GLException
-
getNumBuffers
int getNumBuffers()
- Returns:
- the number of buffers (FBO) being used. 1 if not using
double buffering, otherwise ≥ 2, depending onsetNumBuffers(int).
-
getFBObject
FBObject getFBObject(int bufferName) throws IllegalArgumentException
If MSAA is being used andGL.GL_FRONTis requested, the internalFBObjectsample sinkis being returned.- Parameters:
bufferName-GL.GL_FRONTandGL.GL_BACKare valid buffer names- Returns:
- the named
FBObject - Throws:
IllegalArgumentException- if an illegal buffer name is being used
-
getColorbuffer
FBObject.Colorbuffer getColorbuffer(int bufferName) throws IllegalArgumentException
Returns the namedFBObject.Colorbufferinstance.If MSAA is being used, only the
GL.GL_FRONTbuffer is accessible and an exception is being thrown ifGL.GL_BACKis being requested.Depending on the
fbo modethe resultingFBObject.Colorbufferis either aFBObject.TextureAttachmentifFBOMODE_USE_TEXTUREis set, otherwise aFBObject.ColorAttachment. SeeFBObject.Colorbuffer.isTextureAttachment().- Parameters:
bufferName-GL.GL_FRONTandGL.GL_BACKare valid buffer names- Returns:
- the named
FBObject.Colorbuffer - Throws:
IllegalArgumentException- if using MSAA andGL.GL_BACKis requested or an illegal buffer name is being used
-
-