Class GLDrawableUtil
- java.lang.Object
-
- com.jogamp.opengl.util.GLDrawableUtil
-
public class GLDrawableUtil extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGLDrawableUtil.ReshapeGLEventListenerGLRunnableto issueGLEventListener.reshape(GLAutoDrawable, int, int, int, int), returningtrueonGLRunnable.run(GLAutoDrawable).
-
Constructor Summary
Constructors Constructor Description GLDrawableUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisAnimatorAnimating(GLAnimatorControl animatorCtrl)static booleanisAnimatorAnimatingOnOtherThread(GLAnimatorControl animatorCtrl)static booleanisAnimatorStarted(GLAnimatorControl animatorCtrl)static booleanisAnimatorStartedOnOtherThread(GLAnimatorControl animatorCtrl)static booleanisSwapGLContextSafe(GLCapabilitiesImmutable requestedCaps, GLCapabilitiesImmutable chosenCapsA, GLCapabilitiesImmutable chosenCapsB)Return a heuristic value whether switching theGLContextis safe betweenGLAutoDrawables, i.e.static voidmoveAllGLEventListener(GLAutoDrawable src, GLAutoDrawable dest, boolean preserveInitState)static voidmoveGLEventListener(GLAutoDrawable src, GLAutoDrawable dest, GLEventListener listener, boolean preserveInitState)static booleanswapBuffersBeforeRead(GLCapabilitiesImmutable chosenCaps)Determines whether the chosenGLCapabilitiesImmutablerequires aswap-buffersbefore reading pixels.static voidswapGLContext(GLAutoDrawable a, GLAutoDrawable b)static voidswapGLContextAndAllGLEventListener(GLAutoDrawable a, GLAutoDrawable b)Swaps theGLContextand allGLEventListenerbetweenGLAutoDrawableaandb, while preserving it's initialized state, resets the GL-Viewport and issuingreshape(..).
-
-
-
Method Detail
-
isAnimatorStartedOnOtherThread
public static final boolean isAnimatorStartedOnOtherThread(GLAnimatorControl animatorCtrl)
-
isAnimatorStarted
public static final boolean isAnimatorStarted(GLAnimatorControl animatorCtrl)
-
isAnimatorAnimatingOnOtherThread
public static final boolean isAnimatorAnimatingOnOtherThread(GLAnimatorControl animatorCtrl)
-
isAnimatorAnimating
public static final boolean isAnimatorAnimating(GLAnimatorControl animatorCtrl)
-
moveGLEventListener
public static final void moveGLEventListener(GLAutoDrawable src, GLAutoDrawable dest, GLEventListener listener, boolean preserveInitState)
Moves the designatedGLEventListenerfromGLAutoDrawablesrctodest. IfpreserveInitStateistrue, it's initialized state is preserved andreshape(..)issued w/ the nextGLAutoDrawable.display()call.Note that it is only legal to pass
preserveInitState := true, if theGLContextof bothsrcanddestare shared, or has itself moved fromsrctodest.Also note that the caller is encouraged to pause an attached
GLAnimatorControl.- Parameters:
src-dest-listener-preserveInitState-
-
moveAllGLEventListener
public static final void moveAllGLEventListener(GLAutoDrawable src, GLAutoDrawable dest, boolean preserveInitState)
Moves allGLEventListenerfromGLAutoDrawablesrctodest. IfpreserveInitStateistrue, it's initialized state is preserved andreshape(..)issued w/ the nextGLAutoDrawable.display()call.Note that it is only legal to pass
preserveInitState := true, if theGLContextof bothsrcanddestare shared, or has itself moved fromsrctodest.Also note that the caller is encouraged to pause an attached
GLAnimatorControl.- Parameters:
src-dest-listener-preserveInitState-
-
isSwapGLContextSafe
public static boolean isSwapGLContextSafe(GLCapabilitiesImmutable requestedCaps, GLCapabilitiesImmutable chosenCapsA, GLCapabilitiesImmutable chosenCapsB)
Return a heuristic value whether switching theGLContextis safe betweenGLAutoDrawables, i.e. viaswapGLContext(GLAutoDrawable, GLAutoDrawable)orswapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable).Method currently returns
falseif:- Switching between on- and offscreen and one of the following is
true:MSAA is used[1] inchosenCapsAorchosenCapsBStereo is usedinchosenCapsAorchosenCapsBAccumulator Buffer is requested[2] inrequestedCaps
true[1] See Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX On NVidia GPUs w/ it's proprietary driver context swapping does not work if MSAA is involved and when swapping on- to offscreen.[2] On AMD GPUs w/ it's proprietary driver, requesting an accumulator buffer leads to receive an accumulator buffer configuration, for which context swapping does not work when swapping on- to offscreen and vice-versa, i.e. cannot make context current. With AMD and Mesa drivers we only receive an accumulator buffer if requested, where on NVidia drivers all configurations contain the accumulator buffer. On both drivers, NVidia and Mesa, context swapping with accumulator buffer works.- Parameters:
requestedCaps- requestedGLCapabilitiesImmutablewhich are intended for usage by bothGLAutoDrawables A and BchosenCapsA- chosenGLCapabilitiesImmutableofGLAutoDrawableA, whichGLContextis intended to be swappedchosenCapsB- chosenGLCapabilitiesImmutableofGLAutoDrawableB, whichGLContextis intended to be swapped- See Also:
swapGLContext(GLAutoDrawable, GLAutoDrawable),swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable)
- Switching between on- and offscreen and one of the following is
-
swapGLContextAndAllGLEventListener
public static final void swapGLContextAndAllGLEventListener(GLAutoDrawable a, GLAutoDrawable b)
Swaps theGLContextand allGLEventListenerbetweenGLAutoDrawableaandb, while preserving it's initialized state, resets the GL-Viewport and issuingreshape(..).The
GLAutoDrawabletoGLAnimatorControlassociation is also swapped.If an
GLAnimatorControlis being attached toGLAutoDrawableaorband the current thread is different thanthe animator's thread, it is paused during the operation.During operation, both
auto-drawable'supstream-locksandsurfacesare locked, hence atomicity of operation is guaranteed, see GLAutoDrawable Locking.Because of above mentioned locking, if this method is not performed on
a OpenGL capable threadof bothGLAutoDrawables, it must be invoked on such an OpenGL capable thread, e.g. viaThreading.invokeOnOpenGLThread(boolean, Runnable).- Throws:
GLException- if theAbstractGraphicsDeviceare incompatible w/ each other.- See Also:
isSwapGLContextSafe(GLCapabilitiesImmutable, GLCapabilitiesImmutable, GLCapabilitiesImmutable)
-
swapGLContext
public static final void swapGLContext(GLAutoDrawable a, GLAutoDrawable b)
Swaps theGLContextof givenGLAutoDrawableanddisposeseachGLEventListenerw/o removing it.The GL-Viewport is reset and
reshape(..)issued implicit.If an
GLAnimatorControlis being attached to GLAutoDrawable src or dest and the current thread is different thanthe animator's thread, it is paused during the operation.During operation, both
auto-drawable'supstream-locksandsurfacesare locked, hence atomicity of operation is guaranteed, see GLAutoDrawable Locking.Because of above mentioned locking, if this method is not performed on
a OpenGL capable threadof bothGLAutoDrawables, it must be invoked on such an OpenGL capable thread, e.g. viaThreading.invokeOnOpenGLThread(boolean, Runnable).- Parameters:
a-b-- See Also:
isSwapGLContextSafe(GLCapabilitiesImmutable, GLCapabilitiesImmutable, GLCapabilitiesImmutable)
-
swapBuffersBeforeRead
public static final boolean swapBuffersBeforeRead(GLCapabilitiesImmutable chosenCaps)
Determines whether the chosenGLCapabilitiesImmutablerequires aswap-buffersbefore reading pixels.Usually one uses the
default-read-bufferin which caseswap-buffersshall happen after calling reading pixels, the default.However, multisampling offscreen
GLFBODrawables utilizeswap-buffersto downsample the multisamples into the readable sampling sink. In this case, we requireswap-buffersbefore reading pixels.- Returns:
- chosenCaps.isFBO() && chosenCaps.getSampleBuffers()
-
-