28package com.jogamp.opengl.util;
30import com.jogamp.nativewindow.AbstractGraphicsDevice;
31import com.jogamp.nativewindow.NativeSurface;
32import com.jogamp.opengl.GLAnimatorControl;
33import com.jogamp.opengl.GLAutoDrawable;
34import com.jogamp.opengl.GLBase;
35import com.jogamp.opengl.GLCapabilitiesImmutable;
36import com.jogamp.opengl.GLContext;
37import com.jogamp.opengl.GLDrawable;
38import com.jogamp.opengl.GLEventListener;
39import com.jogamp.opengl.GLException;
40import com.jogamp.opengl.GLRunnable;
41import com.jogamp.opengl.Threading;
43import com.jogamp.common.util.locks.RecursiveLock;
44import com.jogamp.opengl.GLEventListenerState;
46import jogamp.opengl.Debug;
52 protected static final boolean DEBUG = Debug.debug(
"GLDrawable");
55 return (
null != animatorCtrl ) ? animatorCtrl.
isStarted() && animatorCtrl.
getThread() != Thread.currentThread() : false ;
59 return (
null != animatorCtrl ) ? animatorCtrl.
isStarted() : false ;
63 return (
null != animatorCtrl ) ? animatorCtrl.
isAnimating() && animatorCtrl.
getThread() != Thread.currentThread() : false ;
67 return (
null != animatorCtrl ) ? animatorCtrl.
isAnimating() : false ;
76 private final boolean displayAfterReshape;
85 this.listener = listener;
86 this.displayAfterReshape = displayAfterReshape;
91 if( displayAfterReshape ) {
116 if( preserveInitState ) {
194 usingAccumulatorBuffer
235 gllsA.
moveTo(b, gllsBUnlockOp);
236 gllsB.
moveTo(a, gllsAUnlockOp);
279 aUpstreamLock.lock();
280 bUpstreamLock.lock();
283 final boolean aSurfaceLocked = NativeSurface.LOCK_SURFACE_NOT_READY < aSurface.
lockSurface();
285 throw new GLException(
"Could not lock realized a surface "+a);
288 final boolean bSurfaceLocked = NativeSurface.LOCK_SURFACE_NOT_READY < bSurface.
lockSurface();
290 throw new GLException(
"Could not lock realized b surface "+b);
302 if( bSurfaceLocked ) {
305 if( aSurfaceLocked ) {
310 bUpstreamLock.unlock();
311 aUpstreamLock.unlock();
313 a.
invoke(
true, setViewport);
314 b.
invoke(
true, setViewport);
315 if(aIsPaused) { aAnim.
resume(); }
316 if(bIsPaused) { bAnim.
resume(); }
GLEventListenerState is holding GLAutoDrawable components crucial to relocating all its GLEventListen...
final void moveTo(final GLAutoDrawable dest)
Moves all GLEventListenerState components to the given GLAutoDrawable from this instance,...
static GLEventListenerState moveFrom(final GLAutoDrawable src)
Moves all GLEventListenerState components from the given GLAutoDrawable to a newly created instance.
Runnable getUnlockSurfaceOp()
Returns a Runnable unlocking an eventually locked NativeSurface, see moveFrom(GLAutoDrawable,...
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
GLRunnable to issue GLEventListener#reshape(GLAutoDrawable, int, int, int, int), returning true on GL...
ReshapeGLEventListener(final GLEventListener listener, final boolean displayAfterReshape)
boolean run(final GLAutoDrawable drawable)
Providing utility functions dealing w/ GLDrawables, GLAutoDrawable and their GLEventListener.
static final void moveAllGLEventListener(final GLAutoDrawable src, final GLAutoDrawable dest, final boolean preserveInitState)
Moves all GLEventListener from GLAutoDrawable src to dest.
static final boolean isAnimatorAnimatingOnOtherThread(final GLAnimatorControl animatorCtrl)
static final boolean swapBuffersBeforeRead(final GLCapabilitiesImmutable chosenCaps)
Determines whether the chosen GLCapabilitiesImmutable requires a swap-buffers before reading pixels.
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 ini...
static final boolean DEBUG
static final void swapGLContext(final GLAutoDrawable a, final GLAutoDrawable b)
Swaps the GLContext of given GLAutoDrawable and disposes each GLEventListener w/o removing it.
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.
static final boolean isAnimatorStarted(final GLAnimatorControl animatorCtrl)
static final boolean isAnimatorStartedOnOtherThread(final GLAnimatorControl animatorCtrl)
static final boolean isAnimatorAnimating(final GLAnimatorControl animatorCtrl)
static boolean isSwapGLContextSafe(final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesImmutable chosenCapsA, final GLCapabilitiesImmutable chosenCapsB)
Return a heuristic value whether switching the GLContext is safe between GLAutoDrawables,...
boolean isOnscreen()
Returns whether an on- or offscreen surface is requested, available or chosen.
Provides low-level information required for hardware-accelerated rendering using a surface in a platf...
int lockSurface()
Lock the surface of this native window.
void unlockSurface()
Unlock the surface of this native window.
An animator control interface, which implementation may drive a com.jogamp.opengl....
boolean resume()
Resumes animation if paused.
boolean isAnimating()
Indicates whether this animator is started and is not paused.
boolean pause()
Pauses this animator.
boolean isStarted()
Indicates whether this animator has been started.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GLEventListener getGLEventListener(int index)
Returns the GLEventListener at the given index of this drawable queue.
GLContext setContext(GLContext newCtx, boolean destroyPrevCtx)
Associate the new context, newtCtx, to this auto-drawable.
boolean invoke(boolean wait, GLRunnable glRunnable)
Enqueues a one-shot GLRunnable, which will be executed within the next display() call after all regis...
GLAnimatorControl getAnimator()
GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove)
Disposes the given listener via dispose(..) if it has been initialized and added to this queue.
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
void setGLEventListenerInitState(GLEventListener listener, boolean initialized)
Sets the given listener's initialized state.
RecursiveLock getUpstreamLock()
Returns the recursive lock object of the upstream widget to synchronize multithreaded access on top o...
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
int getGLEventListenerCount()
Returns the number of GLEventListener of this drawable queue.
GLEventListener removeGLEventListener(GLEventListener listener)
Removes the given listener from this drawable queue.
GLContext getContext()
Returns the context associated with this drawable.
boolean getGLEventListenerInitState(GLEventListener listener)
Retrieves whether the given listener is initialized or not.
Specifies an immutable set of OpenGL capabilities.
boolean getSampleBuffers()
Returns whether sample buffers for full-scene antialiasing (FSAA) should be allocated for this drawab...
int getAccumGreenBits()
Returns the number of bits for the accumulation buffer's green component.
int getAccumRedBits()
Returns the number of bits for the accumulation buffer's red component.
int getAccumAlphaBits()
Returns the number of bits for the accumulation buffer's alpha component.
int getAccumBlueBits()
Returns the number of bits for the accumulation buffer's blue component.
boolean isFBO()
Returns whether FBO offscreen mode is requested, available or chosen.
boolean getStereo()
Returns whether stereo is requested, available or chosen.
int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
boolean isRealized()
Returns true if this drawable is realized, otherwise false.
NativeSurface getNativeSurface()
Returns the associated NativeSurface of this NativeSurfaceHolder.
int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
void display(GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
Called by the drawable during the first repaint after the component has been resized.
void glViewport(int x, int y, int width, int height)
Entry point to C language function: void {@native glViewport}(GLint x, GLint y, GLsizei width,...