GLDrawable which supplies
an event based mechanism (GLEventListener) for performing
OpenGL rendering. A GLAutoDrawable automatically creates a primary
rendering context which is associated with the GLAutoDrawable for
the lifetime of the object.
Since the GLContext makeCurrent
implementation is synchronized, i.e. blocks if the context
is current on another thread, the internal
GLContext for the GLAutoDrawable can be used for the event
based rendering mechanism and by end users directly.
The implementation shall initialize itself as soon as possible,
which is only possible after the attached NativeSurface becomes visible and and is realized.
The following initialization sequence should be implemented:
GLDrawable with the requested GLCapabilitiesGLDrawable to validate the GLCapabilities by calling setRealized(true).GLContext.init(..) for all
registered GLEventListeners. This can be done immediately, or with the followup display(..) call.reshape(..) for all
registered GLEventListeners. This shall be done after the init(..) calls.GLEventListener actions shall be also performed, when adding
a new one to an already initialized GLAutoDrawable.
Another implementation detail is the GLDrawable reconfiguration. One use case is where a window is being
dragged to another screen with a different pixel configuration, ie GLCapabilities. The implementation
shall be able to detect such cases in conjunction with the associated NativeSurface.
For example, AWT's java. 's getGraphicsConfiguration()
is capable to determine a display device change. This is demonstrated within com.'s
and NEWT's AWTCanvas getGraphicsConfiguration()
specialization. Another demonstration is NEWT's NativeWindow
implementation on the Windows platform, which utilizes the native platform's MonitorFromWindow(HWND) function.
All OpenGL resources shall be regenerated, while the drawable's GLCapabilities has
to be chosen again. The following protocol shall be satisfied.
dispose(..) for all
registered GLEventListeners.GLContext.GLDrawable of the invalid state by calling setRealized(false).GLDrawable with the requested GLCapabilities
GLDrawable to revalidate the GLCapabilities by calling setRealized(true).GLContext.init(..) for all
registered GLEventListeners. This can be done immediatly, or with the followup display(..) call.reshape(..) for all
registered GLEventListeners. This shall be done after the init(..) calls.
Avoiding breakage with older applications and because of the situation
mentioned above, the boolean system property jogl.screenchange.action will control the
screen change action as follows:
-Djogl.screenchange.action=false Disable theGLDrawablereconfiguration (the default) -Djogl.screenchange.action=true Enable theGLDrawablereconfiguration
| Modifier and Type | Field and Description |
|---|---|
| public static final boolean | SCREEN_CHANGE_ACTION_ENABLED
Flag reflecting whether the |
| Modifier and Type | Method and Description |
|---|---|
| public void | addGLEventListener(GLEventListener
The GLEventListener object to be inserted listener)Adds the given |
| public void | addGLEventListener(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, GLEventListener The GLEventListener object to be inserted listener)Adds the given |
| public boolean | areAllGLEventListenerInitialized()
Returns true if all added |
| public GLContext | createContext(GLContext shareWith)
Redeclares com. |
| public void | |
| public void | display()
Causes OpenGL rendering to be performed for this GLAutoDrawable in the following order:
|
| public GLEventListener | Returns: the disposed and/or removed GLEventListener, or null if no action was performed, i.e. listener was not addedThe GLEventListener object to be disposed and removed if listener, boolean remove is truepass remove)true to have the listener removed from this drawable queue, otherwise pass falseDisposes the given |
| public void | flushGLRunnables()
Flushes all |
| public GLAnimatorControl | Returns: the registeredcom. implementation, using this GLAutoDrawable.
|
| public boolean | |
| public GLContext | |
| public int | |
| public GLDrawable | getDelegatedDrawable()
If the implementation uses delegation, return the delegated |
| public Thread | |
| public GL | |
| public GLEventListener | Returns: The GLEventListener object at the given index.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)Returns the |
| public int | Returns: The number of GLEventListener objects of this drawable queue.Returns the number of |
| public boolean | getGLEventListenerInitState(GLEventListener
the GLEventListener object to query it's initialized state. listener)Retrieves whether the given |
| public RecursiveLock | getUpstreamLock()
Returns the recursive lock object of the |
| public Object | getUpstreamWidget()
Method may return the upstream UI toolkit object
holding this |
| public boolean | invoke(boolean
if wait, GLRunnable true block until execution of glRunnable is finished, otherwise return immediately w/o waitingthe glRunnable)GLRunnable to execute within display()Enqueues a one-shot |
| public boolean | invoke(boolean
if wait, List<GLRunnable> true block until execution of the last glRunnable is finished, otherwise return immediately w/o waitingthe glRunnables)GLRunnables to execute within display()Extends |
| public boolean | isThreadGLCapable()
Indicates whether the current thread is capable of performing OpenGL-related work. |
| public GLEventListener | Returns: the removed GLEventListener, or null if listener was not addedThe GLEventListener object to be removed listener)Removes the given |
| public void | setAnimator(GLAnimatorControl
null reference indicates no animator is using
this GLAutoDrawable,a valid reference indicates an animator is using this GLAutoDrawable.Registers the usage of an animator, an |
| public void | setAutoSwapBufferMode(boolean enable)
Enables or disables automatic buffer swapping for this drawable. |
| public GLContext | Returns: the previous GLContext, maybenullthe new context, maybe newCtx, boolean null for dis-association.if destroyPrevCtx)true, destroy the previous context if existsAssociate the new context, |
| public void | |
| public Thread | Returns: previous exclusive context threadthe exclusive thread to claim the context, or t)null for default operation.Dedicates this instance's |
| public GL | |
| public void | setGLEventListenerInitState(GLEventListener
the GLEventListener object to perform a state change. listener, boolean if initialized)true, mark the listener initialized, otherwise uninitialized.Sets the given |
| SCREEN_CHANGE_ACTION_ENABLED | back to summary |
|---|---|
| public static final boolean SCREEN_CHANGE_ACTION_ENABLED Flag reflecting whether the | |
| addGLEventListener | back to summary |
|---|---|
| public void addGLEventListener(GLEventListener listener) Adds the given
The newly added listener's
| |
| addGLEventListener | back to summary |
|---|---|
| public void addGLEventListener(int index, GLEventListener listener) throws IndexOutOfBoundsException Adds the given
The newly added listener's
| |
| areAllGLEventListenerInitialized | back to summary |
|---|---|
| public boolean areAllGLEventListenerInitialized() Returns true if all added
| |
| createContext | back to summary |
|---|---|
| public GLContext createContext(GLContext shareWith) Redeclares com. Doc from com. Creates a new context for drawing to this drawable that will optionally share buffer objects, textures and other server-side OpenGL objects with the specified GLContext.
The GLContext
This GLAutoDrawable implementation holds it's own GLContext reference,
thus created a GLContext using this methods won't replace it implicitly.
To replace or set this GLAutoDrawable's GLContext you need to call
The GLAutoDrawable implementation shall also set the
context creation flags as customized w/
| |
| destroy | back to summary |
|---|---|
| public void destroy() Destroys all resources associated with this GLAutoDrawable,
inclusive the GLContext.
If a window is attached to it's implementation, it shall be closed.
Causes disposing of all OpenGL resources
by calling | |
| display | back to summary |
|---|---|
| public void display() Causes OpenGL rendering to be performed for this GLAutoDrawable in the following order:
May be called periodically by a running
Called automatically by the window system toolkit upon receiving a repaint() request,
This routine may also be called manually for better control over the
rendering process. It is legal to call another GLAutoDrawable's
display method from within the
In case of a new generated OpenGL context,
the implementation shall call | |
| disposeGLEventListener | back to summary |
|---|---|
| public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove) Disposes the given
If
If an
Note that this is an expensive operation, since
Use
Also note that this is done from within a particular drawable's
| |
| flushGLRunnables | back to summary |
|---|---|
| public void flushGLRunnables() Flushes all The executor which might have been blocked until notified will be unblocked and all tasks removed from the queue.
| |
| getAnimator | back to summary |
|---|---|
public GLAnimatorControl getAnimator()
| |
| getAutoSwapBufferMode | back to summary |
|---|---|
| public boolean getAutoSwapBufferMode() Indicates whether automatic buffer swapping is enabled for this
drawable. See | |
| getContext | back to summary |
|---|---|
| public GLContext getContext() Returns the context associated with this drawable. The returned context will be synchronized. Don't rely on it's identity, the context may change. | |
| getContextCreationFlags | back to summary |
|---|---|
public int getContextCreationFlags()
| |
| getDelegatedDrawable | back to summary |
|---|---|
| public GLDrawable getDelegatedDrawable() If the implementation uses delegation, return the delegated | |
| getExclusiveContextThread | back to summary |
|---|---|
public Thread getExclusiveContextThread()
| |
| getGL | back to summary |
|---|---|
| public GL getGL() Returns the | |
| getGLEventListener | back to summary |
|---|---|
| public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException Returns the
| |
| getGLEventListenerCount | back to summary |
|---|---|
| public int getGLEventListenerCount() Returns the number of
| |
| getGLEventListenerInitState | back to summary |
|---|---|
| public boolean getGLEventListenerInitState(GLEventListener listener) Retrieves whether the given
After
This methods returns the
| |
| getUpstreamLock | back to summary |
|---|---|
| public RecursiveLock getUpstreamLock() Returns the recursive lock object of the
| |
| getUpstreamWidget | back to summary | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| public Object getUpstreamWidget() Method may return the upstream UI toolkit object
holding this Currently known Java UI toolkits and it's known return types are:
This method may also return | |||||||||||||||||||||
| invoke | back to summary |
|---|---|
| public boolean invoke(boolean wait, GLRunnable glRunnable) throws IllegalStateException Enqueues a one-shot
If no
If an
If
If
The internal queue of
To avoid a deadlock situation which causes an
| |
| invoke | back to summary |
|---|---|
| public boolean invoke(boolean wait, List<GLRunnable> glRunnables) throws IllegalStateException Extends
| |
| isThreadGLCapable | back to summary |
|---|---|
| public boolean isThreadGLCapable() Indicates whether the current thread is capable of performing OpenGL-related work.
Implementation utilizes this knowledge to determine
whether
| |
| removeGLEventListener | back to summary |
|---|---|
| public GLEventListener removeGLEventListener(GLEventListener listener) Removes the given
This is an inexpensive operation, since the removed listener's
Use
Note that if this is done from within a particular drawable's
| |
| setAnimator | back to summary |
|---|---|
| public void setAnimator(GLAnimatorControl animatorControl) throws GLException Registers the usage of an animator, an
This method shall be called by an animator implementation only,
Impacts
| |
| setAutoSwapBufferMode | back to summary |
|---|---|
| public void setAutoSwapBufferMode(boolean enable) Enables or disables automatic buffer swapping for this drawable.
By default this property is set to true; when true, after all
GLEventListeners have been called for a display() event, the
front and back buffers are swapped, displaying the results of
the render. When disabled, the user is responsible for calling
| |
| setContext | back to summary |
|---|---|
| public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx) Associate the new context, Remarks:
| |
| setContextCreationFlags | back to summary |
|---|---|
public void setContextCreationFlags(int flags)
| |
| setExclusiveContextThread | back to summary |
|---|---|
| public Thread setExclusiveContextThread(Thread t) throws GLException Dedicates this instance's
Default non-exclusive behavior is requested via
To release a previous made exclusive thread, a user issues Note Setting a new exclusive thread without properly releasing a previous one will throw an GLException. Note Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation. Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas.
One scenario could be to dedicate the context to the
| |
| setGL | back to summary |
|---|---|
| public GL setGL(GL gl) Sets the
| |
| setGLEventListenerInitState | back to summary |
|---|---|
| public void setGLEventListenerInitState(GLEventListener listener, boolean initialized) Sets the given
This methods allows manually setting the Warning This method does not validate whether the given
This method is only exposed to allow users full control over the
One use case is moving a
| |