Top Description Inners Fields Constructors Methods
com.jogamp.opengl.util

public Class GLDrawableUtil

extends Object
Class Inheritance
Imports
com.jogamp.nativewindow.AbstractGraphicsDevice, .NativeSurface, com.jogamp.opengl.GLAnimatorControl, .GLAutoDrawable, .GLBase, .GLCapabilitiesImmutable, .GLContext, .GLDrawable, .GLEventListener, .GLException, .GLRunnable, .Threading, .GLEventListenerState, com.jogamp.common.util.locks.RecursiveLock, jogamp.opengl.Debug

Providing utility functions dealing w/ GLDrawables, GLAutoDrawable and their GLEventListener.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
protected static final boolean
private static final GLRunnable

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static final boolean
public static final boolean
public static final boolean
public static final boolean
public static boolean
isSwapGLContextSafe(final GLCapabilitiesImmutable
requested GLCapabilitiesImmutable which are intended for usage by both GLAutoDrawables A and B
requestedCaps
,
final GLCapabilitiesImmutable
chosen GLCapabilitiesImmutable of GLAutoDrawable A, which GLContext is intended to be swapped
chosenCapsA
,
final GLCapabilitiesImmutable
chosen GLCapabilitiesImmutable of GLAutoDrawable B, which GLContext is intended to be swapped
chosenCapsB
)

Return a heuristic value whether switching the GLContext is safe between GLAutoDrawables, i.e. via swapGLContext(GLAutoDrawable, GLAutoDrawable) or swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable).

public static final void
moveAllGLEventListener(final GLAutoDrawable src, final GLAutoDrawable dest, final boolean preserveInitState)

Moves all GLEventListener from GLAutoDrawable src to dest.

public static final void
moveGLEventListener(final GLAutoDrawable src, final GLAutoDrawable dest, final GLEventListener listener, final boolean preserveInitState)

Moves the designated GLEventListener from GLAutoDrawable src to dest.

public static final boolean

Returns:

chosenCaps.isFBO() && chosenCaps.getSampleBuffers()
swapBuffersBeforeRead
(final GLCapabilitiesImmutable chosenCaps)

Determines whether the chosen GLCapabilitiesImmutable requires a swap-buffers before reading pixels.

public static final void
swapGLContext(final GLAutoDrawable a, final GLAutoDrawable b)

Swaps the GLContext of given GLAutoDrawable and disposes each GLEventListener w/o removing it.

public static final void
swapGLContextAndAllGLEventListener(final GLAutoDrawable a, final GLAutoDrawable b)

Swaps the GLContext and all GLEventListener between GLAutoDrawable a and b, while preserving it's initialized state, resets the GL-Viewport and issuing reshape(..).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEBUGback to summary
protected static final boolean DEBUG
setViewportback to summary
private static final GLRunnable setViewport

Constructor Detail

GLDrawableUtilback to summary
public GLDrawableUtil()

Method Detail

isAnimatorAnimatingback to summary
public static final boolean isAnimatorAnimating(final GLAnimatorControl animatorCtrl)
isAnimatorAnimatingOnOtherThreadback to summary
public static final boolean isAnimatorAnimatingOnOtherThread(final GLAnimatorControl animatorCtrl)
isAnimatorStartedback to summary
public static final boolean isAnimatorStarted(final GLAnimatorControl animatorCtrl)
isAnimatorStartedOnOtherThreadback to summary
public static final boolean isAnimatorStartedOnOtherThread(final GLAnimatorControl animatorCtrl)
isSwapGLContextSafeback to summary
public static boolean isSwapGLContextSafe(final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesImmutable chosenCapsA, final GLCapabilitiesImmutable chosenCapsB)

Return a heuristic value whether switching the GLContext is safe between GLAutoDrawables, i.e. via swapGLContext(GLAutoDrawable, GLAutoDrawable) or swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable).

Method currently returns false if:

Otherwise method returns 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:GLCapabilitiesImmutable

requested GLCapabilitiesImmutable which are intended for usage by both GLAutoDrawables A and B

chosenCapsA:GLCapabilitiesImmutable

chosen GLCapabilitiesImmutable of GLAutoDrawable A, which GLContext is intended to be swapped

chosenCapsB:GLCapabilitiesImmutable

chosen GLCapabilitiesImmutable of GLAutoDrawable B, which GLContext is intended to be swapped

See Also
swapGLContext(GLAutoDrawable, GLAutoDrawable), swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable)
moveAllGLEventListenerback to summary
public static final void moveAllGLEventListener(final GLAutoDrawable src, final GLAutoDrawable dest, final boolean preserveInitState)

Moves all GLEventListener from GLAutoDrawable src to dest. If preserveInitState is true, it's initialized state is preserved and reshape(..) issued w/ the next GLAutoDrawable#display() call.

Note that it is only legal to pass preserveInitState := true, if the GLContext of both src and dest are shared, or has itself moved from src to dest.

Also note that the caller is encouraged to pause an attached GLAnimatorControl.

moveGLEventListenerback to summary
public static final void moveGLEventListener(final GLAutoDrawable src, final GLAutoDrawable dest, final GLEventListener listener, final boolean preserveInitState)

Moves the designated GLEventListener from GLAutoDrawable src to dest. If preserveInitState is true, it's initialized state is preserved and reshape(..) issued w/ the next GLAutoDrawable#display() call.

Note that it is only legal to pass preserveInitState := true, if the GLContext of both src and dest are shared, or has itself moved from src to dest.

Also note that the caller is encouraged to pause an attached GLAnimatorControl.

swapBuffersBeforeReadback to summary
public static final boolean swapBuffersBeforeRead(final GLCapabilitiesImmutable chosenCaps)

Determines whether the chosen GLCapabilitiesImmutable requires a swap-buffers before reading pixels.

Usually one uses the default-read-buffer in which case swap-buffers shall happen after calling reading pixels, the default.

However, multisampling offscreen com.jogamp.opengl.GLFBODrawables utilize swap-buffers to downsample the multisamples into the readable sampling sink. In this case, we require swap-buffers before reading pixels.

Returns:boolean

chosenCaps.isFBO() && chosenCaps.getSampleBuffers()

swapGLContextback to summary
public static final void swapGLContext(final GLAutoDrawable a, final GLAutoDrawable b)

Swaps the GLContext of given GLAutoDrawable and disposes each GLEventListener w/o removing it.

The GL-Viewport is reset and reshape(..) issued implicit.

If an GLAnimatorControl is being attached to GLAutoDrawable src or dest and the current thread is different than the animator's thread, it is paused during the operation.

During operation, both auto-drawable's upstream-locks and surfaces are 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 thread of both GLAutoDrawables, it must be invoked on such an OpenGL capable thread, e.g. via Threading#invokeOnOpenGLThread(boolean, Runnable).

See Also
isSwapGLContextSafe(GLCapabilitiesImmutable, GLCapabilitiesImmutable, GLCapabilitiesImmutable)
swapGLContextAndAllGLEventListenerback to summary
public static final void swapGLContextAndAllGLEventListener(final GLAutoDrawable a, final GLAutoDrawable b)

Swaps the GLContext and all GLEventListener between GLAutoDrawable a and b, while preserving it's initialized state, resets the GL-Viewport and issuing reshape(..).

The GLAutoDrawable to GLAnimatorControl association is also swapped.

If an GLAnimatorControl is being attached to GLAutoDrawable a or b and the current thread is different than the animator's thread, it is paused during the operation.

During operation, both auto-drawable's upstream-locks and surfaces are 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 thread of both GLAutoDrawables, it must be invoked on such an OpenGL capable thread, e.g. via Threading#invokeOnOpenGLThread(boolean, Runnable).

Exceptions
GLException:
if the AbstractGraphicsDevice are incompatible w/ each other.
See Also
isSwapGLContextSafe(GLCapabilitiesImmutable, GLCapabilitiesImmutable, GLCapabilitiesImmutable)
com.jogamp.opengl.util back to summary

public Class GLDrawableUtil.ReshapeGLEventListener

extends Object
implements GLRunnable
Class Inheritance
All Implemented Interfaces
com.jogamp.opengl.GLRunnable

GLRunnable to issue GLEventListener#reshape(GLAutoDrawable, int, int, int, int), returning true on GLRunnable#run(GLAutoDrawable).

Field Summary

Modifier and TypeField and Description
private final boolean
private final GLEventListener

Constructor Summary

AccessConstructor and Description
public
ReshapeGLEventListener(final GLEventListener listener, final boolean displayAfterReshape)

Method Summary

Modifier and TypeMethod and Description
public boolean
run(final GLAutoDrawable
the associated drawable and current context for this call
drawable
)

Implements com.jogamp.opengl.GLRunnable.run.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

displayAfterReshapeback to summary
private final boolean displayAfterReshape
listenerback to summary
private final GLEventListener listener

Constructor Detail

ReshapeGLEventListenerback to summary
public ReshapeGLEventListener(final GLEventListener listener, final boolean displayAfterReshape)
Parameters
displayAfterReshape:boolean

true to issue GLEventListener#display(GLAutoDrawable) after GLEventListener#reshape(GLAutoDrawable, int, int, int, int), otherwise false.

Method Detail

runback to summary
public boolean run(final GLAutoDrawable drawable)

Implements com.jogamp.opengl.GLRunnable.run.

Parameters
drawable:GLAutoDrawable

Doc from com.jogamp.opengl.GLRunnable.run.

the associated drawable and current context for this call

Returns:boolean

Doc from com.jogamp.opengl.GLRunnable.run.

true if the GL [back] framebuffer remains intact by this runnable, otherwise false. If returning false GLAutoDrawable will call display(GLAutoDrawable) of all registered GLEventListeners once more.

Annotations
@Override