The GLJPanel can be made transparent by creating it with a
GLCapabilities object with alpha bits specified and calling setOpaque(false). Pixels with resulting OpenGL alpha values less
than 1.0 will be overlaid on any underlying Swing rendering.
This component attempts to use hardware-accelerated rendering via FBO or pbuffers and
falls back on to software rendering if none of the former are available
using GLDrawableFactory..
A vertical-flip is required, if the drawable isGLOriented() and vertical flip is not skipped.
In this case this component performs the required vertical flip to bring the content from OpenGL's orientation into AWT's orientation.
In case GLSL based vertical-flip is not available,
the CPU intensive System. is used line by line.
See details about FBO and GLSL vertical flipping.
For performance reasons, as well as for GL state sideeffects,
skipping vertical flip is highly recommended!
The OpenGL path is concluded by copying the rendered pixels an BufferedImage via glReadPixels(.
for later Java2D composition.
Finally the Java2D compositioning takes place via via Graphics.
on the prepared BufferedImage as described above.
Please read Java2D OpenGL Remarks.
vertical flip is not skipped, a fragment shader is utilized
to flip the FBO texture vertically. This hardware-accelerated step can be disabled via system property jogl.gljpanel.noglsl.
The FBO / GLSL code path uses one texture-unit and binds the FBO texture to it's active texture-target,
see setTextureUnit(int) and getTextureUnit().
The active and dedicated texture-unit's GL#GL_TEXTURE_2D state is preserved via TextureState.
See also Order of Texture Commands.
The current gl-viewport is preserved.
Warning (Bug 842): Certain GL states other than viewport and texture (see above)
influencing rendering, will also influence the GLSL vertical flip, e.g. glFrontFace(GL#GL_CCW).
It is recommended to reset those states to default when leaving the GLEventListener#display(GLAutoDrawable) method!
We may change this behavior in the future, i.e. preserve all influencing states.
OpenGL Context Sharing
To share a GLContext see the following note in the documentation overview:
context sharing
as well as GLSharedContextSetter.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static interface | GLJPanel.
Abstraction of the different rendering backends: i.e., pure software / pixmap rendering, pbuffer-based acceleration, Java 2D JOGL bridge |
| private class | |
| pack-priv class | |
| pack-priv class | |
| pack-priv class |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private boolean | |
| private final AWTWindowClosingProtocol | |
| private volatile GLJPanel. | |
| private final GLCapabilitiesChooser | |
| private AWTGLPixelBuffer. | |
| private static final boolean | |
| private static final boolean | |
| private static final boolean | |
| private final Runnable | |
| private volatile GLDrawableFactoryImpl | |
| private boolean | |
| private final float[] | |
| private final GLDrawableHelper | |
| private final HierarchyListener | |
| private final Object | |
| private volatile boolean | |
| private volatile boolean | |
| private static boolean | java2DGLPipelineOK
Indicates whether the Java 2D OpenGL pipeline's usage is error free. |
| private static final boolean | java2dOGLEnabledByProp
Indicates whether the Java 2D OpenGL pipeline is requested by user. |
| private final RecursiveLock | |
| private final float[] | |
| private final float[] | |
| private final Runnable | |
| private int | panelHeight
Scaled pixel height of the actual GLJPanel: reshapeHeight -> panelHeight -> backend.height |
| private int | panelWidth
Scaled pixel width of the actual GLJPanel: reshapeWidth -> panelWidth -> backend.width |
| private volatile boolean | |
| private GLAnimatorControl | |
| private AWTTilePainter | |
| private GLAutoDrawable | |
| private final Runnable | |
| private volatile GLCapabilitiesImmutable | reqOffscreenCaps
Requested single buffered offscreen caps |
| private final float[] | |
| private int | |
| private int | reshapeHeight
For handling reshape events lazily: reshapeHeight -> panelHeight -> backend.height in pixel units (scaled) |
| private int | reshapeWidth
For handling reshape events lazily: reshapeWidth -> panelWidth -> backend.width in pixel units (scaled) |
| private boolean | |
| private final Runnable | |
| private final Runnable | |
| private static AWTGLPixelBuffer. | |
| private static final boolean | |
| private boolean | |
| private final GLJPanel. | |
| private final Runnable | |
| private final Runnable | |
| private final Runnable | |
| private static final boolean | |
| private static final boolean | useJava2DGLPipeline
Indicates whether the Java 2D OpenGL pipeline is enabled, resource-compatible and requested by user. |
| private int | |
| private int |
| Access | Constructor and Description |
|---|---|
| public | GLJPanel()
Creates a new GLJPanel component with a default set of OpenGL capabilities and using the default OpenGL capabilities selection mechanism. |
| public | GLJPanel(final GLCapabilitiesImmutable userCapsRequest)
Creates a new GLJPanel component with the requested set of OpenGL capabilities, using the default OpenGL capabilities selection mechanism. |
| public | GLJPanel(final GLCapabilitiesImmutable userCapsRequest, final GLCapabilitiesChooser chooser)
Creates a new GLJPanel component. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addGLEventListener(final GLEventListener
The GLEventListener object to be inserted listener)Implements com. listener to the end of this drawable queue.
|
| public void | addGLEventListener(final int
Position where the listener will be inserted.
Should be within (0 <= index && index <= size()).
An index value of -1 is interpreted as the end of the list, size(). index, final GLEventListener The GLEventListener object to be inserted listener)Implements com. listener at the given index of this drawable queue.
|
| public void | addNotify()
Overrides javax. |
| public boolean | areAllGLEventListenerInitialized()
Implements com. GLEventListener are initialized, otherwise false.
|
| public GLContext | createContext(final GLContext shareWith)
Implements com. |
| public void | |
| public void | display()
Implements com. Causes OpenGL rendering to be performed for this GLAutoDrawable in the following order:
|
| protected void | |
| public GLEventListener | disposeGLEventListener(final GLEventListener
The GLEventListener object to be disposed and removed if listener, final boolean remove is truepass remove)true to have the listener removed from this drawable queue, otherwise pass falseImplements com. listener via dispose(.
if it has been initialized and added to this queue.
|
| public void | flushGLRunnables()
Implements com. enqueued GLRunnable of this GLAutoDrawable
including notifying waiting executor.
|
| public GLAnimatorControl | |
| public boolean | getAutoSwapBufferMode()
Implements com. |
| public GLCapabilitiesImmutable | getChosenGLCapabilities()
Implements com. GLCapabilitiesImmutable corresponding to the chosen
OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.
|
| public GLContext | getContext()
Implements com. |
| public int | |
| public final float[] | getCurrentSurfaceScale(final float[]
float[2] storage for the result result)Implements com. NativeSurface.
|
| public AWTGLPixelBuffer. | |
| public WindowClosingProtocol. | |
| public final GLDrawable | getDelegatedDrawable()
Implements com. GLDrawable instance,
otherwise return this instance.
|
| public final Thread | |
| public final GLDrawableFactory | getFactory()
Implements com. GLDrawableFactory being used to create this instance.
|
| public GL | getGL()
Implements com. GL pipeline object this GLAutoDrawable uses.
|
| public GLEventListener | getGLEventListener(final int
Position of the listener to be returned.
Should be within (0 <= index && index < size()).
An index value of -1 is interpreted as last listener, size()-1. index)Implements com. GLEventListener at the given index of this drawable queue.
|
| public int | getGLEventListenerCount()
Implements com. GLEventListener of this drawable queue.
|
| public boolean | getGLEventListenerInitState(final GLEventListener
the GLEventListener object to query it's initialized state. listener)Implements com. listener is initialized or not.
|
| private int | |
| public final GLProfile | getGLProfile()
Implements com. GLProfile for this drawable.
|
| public long | getHandle()
Implements com. realization
and while it's surface is being locked.
|
| public float[] | getMaximumSurfaceScale(final float[]
float[2] storage for the result result)Implements com. NativeSurface.
|
| public float[] | getMinimumSurfaceScale(final float[]
float[2] storage for the result result)Implements com. NativeSurface.
|
| public NativeSurface | getNativeSurface()
Implements com. NativeSurface of this NativeSurfaceHolder.
|
| private final String | |
| public final GLCapabilitiesImmutable | getRequestedGLCapabilities()
Implements com. GLCapabilitiesImmutable corresponding to the user requested
OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.
|
| public final float[] | getRequestedSurfaceScale(final float[]
float[2] storage for the result result)Implements com. requested pixel scale of the associated NativeSurface.
|
| private static synchronized AWTGLPixelBuffer. | |
| public final boolean | |
| public int | getSurfaceHeight()
Implements com. GLDrawable's surface client area in pixel units.
|
| public int | getSurfaceWidth()
Implements com. GLDrawable's surface client area in pixel units.
|
| public final int | |
| protected static String | |
| public final RecursiveLock | getUpstreamLock()
Implements com. upstream widget
to synchronize multithreaded access on top of NativeSurface#lockSurface().
|
| public final Object | getUpstreamWidget()
Implements com. GLAutoDrawable instance, if exist.</td<></td<></td<></td<></td<>
|
| private boolean | |
| public final boolean | initializeBackend(final boolean offthread)
Attempts to initialize the backend, if not initialized yet. |
| private boolean | |
| public boolean | invoke(final boolean
if wait, final GLRunnable true block until execution of glRunnable is finished, otherwise return immediately w/o waitingthe glRunnable)GLRunnable to execute within display()Implements com. GLRunnable,
which will be executed within the next display() call
after all registered GLEventListeners
display(GLAutoDrawable)
methods have been called.
|
| public boolean | invoke(final boolean
if wait, final List<GLRunnable> true block until execution of the last glRunnable is finished, otherwise return immediately w/o waitingthe glRunnables)GLRunnables to execute within display()Implements com. invoke(boolean, GLRunnable) functionality
allowing to inject a list of GLRunnables.
|
| public boolean | isGLOriented()
Implements com. true if the drawable is rendered in
OpenGL's coordinate system, origin at bottom left.
|
| public boolean | isRealized()
Implements com. true if this drawable is realized, otherwise true.
|
| public final boolean | isThreadGLCapable()
Implements com. |
| private boolean | |
| protected void | paintComponent(final Graphics
the g)Graphics object to protectOverrides javax. |
| public void | print(final Graphics
the graphics)Graphics context in which to paintOverrides javax. Graphics.
|
| protected void | printComponent(final Graphics
the g)Graphics context in which to paintOverrides javax. |
| public void | releasePrint()
Implements com. PrinterJob#print().
|
| public GLEventListener | removeGLEventListener(final GLEventListener
The GLEventListener object to be removed listener)Implements com. listener from this drawable queue.
|
| public void | removeNotify()
Overrides javax. |
| public void | reshape(final int
the new horizontal location x, final int the new vertical location y, final int the new width width, final int the new height height)Overrides javax. GLDrawableHelper#reshape to be
called on all registered GLEventListeners.
|
| private void | |
| public void | setAnimator(final GLAnimatorControl
null reference indicates no animator is using
this GLAutoDrawable,a valid reference indicates an animator is using this GLAutoDrawable.Implements com. com. implementation.
|
| public void | setAutoSwapBufferMode(final boolean enable)
Implements com. |
| public GLContext | setContext(final GLContext
the new context, maybe newCtx, final boolean null for dis-association.if destroyPrevCtx)true, destroy the previous context if existsImplements com. newtCtx, to this auto-drawable.
|
| public void | setContextCreationFlags(final int
Additional context creation flags. flags)Implements com. |
| public WindowClosingProtocol. | setDefaultCloseOperation(final WindowClosingProtocol.
the new close operation value opImplements com. |
| public final Thread | setExclusiveContextThread(final Thread
the exclusive thread to claim the context, or t)null for default operation.Implements com. GLContext to the given thread.
|
| public GL | setGL(final GL gl)
Implements com. GL pipeline object this GLAutoDrawable uses.
|
| public void | setGLEventListenerInitState(final GLEventListener
the GLEventListener object to perform a state change. listener, final boolean if initialized)true, mark the listener initialized, otherwise uninitialized.Implements com. listener's initialized state.
|
| public void | setOpaque(final boolean
true if this component should be opaque opaque)Overrides javax. |
| public void | setPixelBufferProvider(final AWTGLPixelBuffer.
custom customAWTGLPixelBufferProvider
|
| public void | setRealized(final boolean realized)
Implements com. surface has been created and can be drawn into.
|
| public final void | setRequestedGLCapabilities(final GLCapabilitiesImmutable
new capabilities. caps)Set a new requested |
| public final void | setSharedAutoDrawable(final GLAutoDrawable
The GLAutoDrawable, which OpenGL context shall be shared by this sharedAutoDrawable)GLAutoDrawable's GLContext.Implements com. GLAutoDrawable, which OpenGL context shall be shared by this GLAutoDrawable's GLContext.
|
| public final void | setSharedContext(final GLContext
The OpenGL context to be shared by this sharedContext)GLAutoDrawable's GLContext.Implements com. OpenGL context, which shall be shared by this GLAutoDrawable's GLContext.
|
| public final void | setSkipGLOrientationVerticalFlip(final boolean v)
Skip |
| public final boolean | setSurfaceScale(final float[]
requested surface pixel scale float[2] values for x- and y-direction. pixelScale)Implements com. NativeSurface,
where size_in_pixel_units = pixel_scale * size_in_window_units.
|
| private final boolean | |
| public final void | setTextureUnit(final int
requested texture unit v)Allows user to request a texture unit to be used,
must be called before the first initialization, i.e. |
| public void | setupPrint(final double
Graphics2D scaling factor, i.e. rendering 1/scaleMatX * width pixelsGraphics2D scaling factor, i.e. rendering 1/scaleMatY * height pixelsmultisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples numSamples, final int custom tile width for tileWidth, final int tile renderer, pass -1 for default.custom tile height for tileHeight)tile renderer, pass -1 for default.
FIXME: Add border size !Implements com. PrinterJob#print().
|
| public boolean | shouldPreserveColorBufferIfTranslucent()
For a translucent GLJPanel (one for which |
| public void | swapBuffers()
Implements com. |
| public String | toString()
Overrides java. Implements com. |
| private final boolean | |
| private final void |