com.jogamp.newt.opengl
Class GLWindow

java.lang.Object
  extended by com.jogamp.newt.opengl.GLWindow
All Implemented Interfaces:
NEWTEventConsumer, Window, NativeSurface, NativeWindow, SurfaceUpdatedListener, WindowClosingProtocol, FPSCounter, GLAutoDrawable, GLDrawable

public class GLWindow
extends Object
implements GLAutoDrawable, Window, NEWTEventConsumer, FPSCounter

An implementation of GLAutoDrawable interface, using an aggregation of a Window implementation.

This implementation does not make the OpenGL context current
before calling the various input EventListener callbacks, ie MouseListener etc.
This design decision is made in favor of a more performant and simplified implementation. Also the event dispatcher shall be implemented OpenGL agnostic.
To be able to use OpenGL commands from within such input NEWTEventListener,
you can inject GLRunnable objects via invoke(boolean, javax.media.opengl.GLRunnable) to the OpenGL command stream.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.jogamp.newt.Window
Window.FocusRunnable, Window.ReparentAction
 
Field Summary
 
Fields inherited from interface javax.media.opengl.GLAutoDrawable
SCREEN_CHANGE_ACTION_ENABLED
 
Fields inherited from interface com.jogamp.newt.Window
DEBUG_IMPLEMENTATION, DEBUG_KEY_EVENT, DEBUG_MOUSE_EVENT, TIMEOUT_NATIVEWINDOW
 
Fields inherited from interface javax.media.nativewindow.NativeSurface
LOCK_SUCCESS, LOCK_SURFACE_CHANGED, LOCK_SURFACE_NOT_READY, LOCK_SURFACE_UNLOCKED
 
Fields inherited from interface javax.media.nativewindow.WindowClosingProtocol
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE
 
Fields inherited from interface javax.media.opengl.FPSCounter
DEFAULT_FRAMES_PER_INTERVAL
 
Method Summary
 boolean addChild(NativeWindow win)
           
 void addGLEventListener(GLEventListener listener)
          Adds a GLEventListener to the end of this drawable queue.
 void addGLEventListener(int index, GLEventListener listener)
          Adds a GLEventListener at the given index of this drawable queue.
 void addKeyListener(int index, KeyListener l)
          Inserts the given KeyListener at the specified position in the list.
 void addKeyListener(KeyListener l)
          Appends the given KeyListener to the end of the list.
 void addMouseListener(int index, MouseListener l)
          Inserts the given MouseListener at the specified position in the list.
 void addMouseListener(MouseListener l)
          Appends the given MouseListener to the end of the list.
 void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l)
          Inserts the given com.jogamp.newt.event.SurfaceUpdatedListener at the specified position in the list.
 void addSurfaceUpdatedListener(SurfaceUpdatedListener l)
          Appends the given com.jogamp.newt.event.SurfaceUpdatedListener to the end of the list.
 void addWindowListener(int index, WindowListener l)
          Inserts the given WindowListener at the specified position in the list.
 void addWindowListener(WindowListener l)
          Appends the given WindowListener to the end of the list.
 boolean consumeEvent(NEWTEvent event)
          Consume the event
static GLWindow create(GLCapabilitiesImmutable caps)
          Creates a new GLWindow attaching a new Window referencing a new Screen with the given GLCapabilities.
static GLWindow create(NativeWindow parentNativeWindow, GLCapabilitiesImmutable caps)
          Creates a new GLWindow attaching a new child Window of the given parentNativeWindow with the given GLCapabilities.
static GLWindow create(Screen screen, GLCapabilitiesImmutable caps)
          Creates a new GLWindow attaching a new Window referencing the given Screen with the given GLCapabilities.
static GLWindow create(Window window)
          Creates a new GLWindow attaching the given window.
 GLContext createContext(GLContext shareWith)
          Creates a new context for drawing to this drawable that will optionally share display lists and other server-side OpenGL objects with the specified GLContext.
 void destroy()
          Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
 void display()
           Causes OpenGL rendering to be performed for this GLAutoDrawable in the following order: Calling display(..) for all registered GLEventListeners.
 void enqueueEvent(boolean wait, NEWTEvent event)
           
 GLAnimatorControl getAnimator()
           
 boolean getAutoSwapBufferMode()
          This implementation uses a static value
 CapabilitiesImmutable getChosenCapabilities()
          Gets an immutable set of chosen capabilities.
 GLCapabilitiesImmutable getChosenGLCapabilities()
          Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.
On some platforms, the pixel format is not directly associated with the drawable; a best attempt is made to return a reasonable value in this case.
 GLContext getContext()
          Returns the context associated with this drawable.
 int getContextCreationFlags()
           
 int getDefaultCloseOperation()
           
 long getDisplayHandle()
          Convenience: Get display handle from AbstractGraphicsConfiguration .
 GLDrawableFactory getFactory()
           
 long getFPSStartTime()
          Returns the time of the first display call in milliseconds after enabling this feature via FPSCounter.setUpdateFPSFrames(int, PrintStream).
This value is reset via FPSCounter.resetFPSCounter().
 GL getGL()
          Returns the GL pipeline object this GLAutoDrawable uses.
 GLProfile getGLProfile()
          Fetches the GLProfile for this drawable.
 AbstractGraphicsConfiguration getGraphicsConfiguration()
          Returns the graphics configuration corresponding to this window.
 long getHandle()
          This is the GL/Windowing drawable handle.
It is usually the NativeSurface.getSurfaceHandle(), ie the native surface handle of the underlying windowing toolkit.
However, on X11/GLX this reflects a GLXDrawable, which represents a GLXWindow, GLXPixmap, or GLXPbuffer.
On EGL, this represents the EGLSurface.
 int getHeight()
          Returns the current height of this GLDrawable.
 InsetsImmutable getInsets()
          Returns the insets defined as the width and height of the window decoration on the left, right, top and bottom.
Insets are zero if the window is undecorated, including child windows.
 KeyListener getKeyListener(int index)
           
 KeyListener[] getKeyListeners()
           
 float getLastFPS()
           
 long getLastFPSPeriod()
           
 long getLastFPSUpdateTime()
          Returns the time of the last update interval in milliseconds, if this feature is enabled via FPSCounter.setUpdateFPSFrames(int, PrintStream).
This value is reset via FPSCounter.resetFPSCounter().
 Point getLocationOnScreen(Point storage)
          Returns the current absolute location of this window.
 MouseListener getMouseListener(int index)
           
 MouseListener[] getMouseListeners()
           
 NativeSurface getNativeSurface()
           
 NativeWindow getParent()
           
 CapabilitiesImmutable getRequestedCapabilities()
          Gets an immutable set of requested capabilities.
 Screen getScreen()
           
 int getScreenIndex()
          Convenience: Get display handle from AbstractGraphicsConfiguration .
 long getSurfaceHandle()
          Returns the handle to the surface for this NativeSurface.
 Thread getSurfaceLockOwner()
          Return the locking owner's Thread, or null if not locked.
 SurfaceUpdatedListener getSurfaceUpdatedListener(int index)
           
 SurfaceUpdatedListener[] getSurfaceUpdatedListeners()
           
 String getTitle()
           
 float getTotalFPS()
           
 long getTotalFPSDuration()
           
 int getTotalFPSFrames()
           
 int getUpdateFPSFrames()
           
 int getWidth()
          Returns the current width of this GLDrawable.
 Window getWindow()
           
 long getWindowHandle()
          Returns the window handle for this NativeWindow.
 WindowListener getWindowListener(int index)
           
 WindowListener[] getWindowListeners()
           
 int getX()
           
 int getY()
           
 boolean hasFocus()
           
 void invoke(boolean wait, GLRunnable glRunnable)
           Enqueues a one-shot GLRunnable, which will be executed with the next GLAutoDrawable.display() call.
 boolean isAlwaysOnTop()
           
 boolean isFullscreen()
           
 boolean isNativeValid()
           
 boolean isRealized()
           
 boolean isSurfaceLocked()
          Return if surface is locked
 boolean isSurfaceLockedByOtherThread()
          Return if surface is locked by another thread, ie not the current one
 boolean isUndecorated()
           
 boolean isVisible()
           
 int lockSurface()
          Lock the surface of this native window
static void main(String[] args)
          A most simple JOGL AWT test entry
 void removeAllSurfaceUpdatedListener()
           
 boolean removeChild(NativeWindow win)
           
 void removeGLEventListener(GLEventListener listener)
          Removes a GLEventListener from this drawable.
 void removeKeyListener(KeyListener l)
           
 void removeMouseListener(MouseListener l)
           
 void removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
           
 void removeWindowListener(WindowListener l)
           
 int reparentWindow(NativeWindow newParent)
          Change this window's parent window.
 int reparentWindow(NativeWindow newParent, boolean forceDestroyCreate)
           
 void requestFocus()
           
 void resetFPSCounter()
          Reset all performance counter (startTime, currentTime, frame number)
 void runOnEDTIfAvail(boolean wait, Runnable task)
           
 void sendWindowEvent(int eventType)
           
 void setAlwaysOnTop(boolean value)
           
 void setAnimator(GLAnimatorControl animatorControl)
           Registers the usage of an animator, an GLAnimatorControl implementation.
 void setAutoSwapBufferMode(boolean onOrOff)
          This implementation uses a static value
 CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser)
          Set the CapabilitiesChooser to help determine the native visual type.
 void setContext(GLContext newCtx)
          Associate a new context to this drawable.
 void setContextCreationFlags(int flags)
           
 int setDefaultCloseOperation(int op)
           
 void setFocusAction(Window.FocusRunnable focusAction)
          May set to a Window.FocusRunnable, Window.FocusRunnable.run() before Newt requests the native focus.
 boolean setFullscreen(boolean fullscreen)
           
 GL setGL(GL gl)
          Sets the GL pipeline object this GLAutoDrawable uses.
 void setPosition(int x, int y)
          Sets the location of the window's client area, excluding insets (window decorations).
This call is ignored if in fullscreen mode.
 void setRealized(boolean realized)
          Indicates to on-screen GLDrawable implementations whether the underlying window has been created and can be drawn into.
 void setSharedContext(GLContext sharedContext)
          Specifies an OpenGL context to share with.
At native creation, setVisible(true), a drawable and context is created besides the native Window itself,
hence you shall set the shared context before.
 void setSize(int width, int height)
          Sets the size of the window's client area, excluding decorations.
 void setTitle(String title)
           
 void setTopLevelPosition(int x, int y)
          Sets the location of the top-level window inclusive insets (window decorations).
 void setTopLevelSize(int width, int height)
          Sets the size of the top-level window including insets (window decorations).
 void setUndecorated(boolean value)
           
 void setUpdateFPSFrames(int frames, PrintStream out)
           
 void setVisible(boolean visible)
           setVisible makes the window and children visible if visible is true, otherwise the window and children becomes invisible.
 boolean surfaceSwap()
          Provide a mechanism to utilize custom (pre-) swap surface code.
 void surfaceUpdated(Object updater, NativeSurface ns, long when)
          Notification of a surface update event.
 void swapBuffers()
          Swaps the front and back buffers of this drawable.
 String toString()
           
 void unlockSurface()
          Unlock the surface of this native window Shall not modify the surface handle, see NativeSurface.lockSurface()
 void windowRepaint(int x, int y, int width, int height)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static GLWindow create(GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new Screen with the given GLCapabilities.

The resulting GLWindow owns the Window, Screen and Device, ie it will be destructed.

The default display connection will be used and reused if already in process.


create

public static GLWindow create(Screen screen,
                              GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing the given Screen with the given GLCapabilities.

The resulting GLWindow owns the Window, ie it will be destructed.


create

public static GLWindow create(Window window)
Creates a new GLWindow attaching the given window.

The resulting GLWindow does not own the given Window, ie it will not be destructed.


create

public static GLWindow create(NativeWindow parentNativeWindow,
                              GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new child Window of the given parentNativeWindow with the given GLCapabilities.

The Display/Screen will be compatible with the parentNativeWindow, or even identical in case it's a Newt Window.

The resulting GLWindow owns the Window, ie it will be destructed.


getDefaultCloseOperation

public int getDefaultCloseOperation()
Specified by:
getDefaultCloseOperation in interface WindowClosingProtocol
Returns:
the current close operation value
See Also:
WindowClosingProtocol.DISPOSE_ON_CLOSE, WindowClosingProtocol.DO_NOTHING_ON_CLOSE

setDefaultCloseOperation

public int setDefaultCloseOperation(int op)
Specified by:
setDefaultCloseOperation in interface WindowClosingProtocol
Parameters:
op - the new close operation value
Returns:
the previous close operation value
See Also:
WindowClosingProtocol.DISPOSE_ON_CLOSE, WindowClosingProtocol.DO_NOTHING_ON_CLOSE

setCapabilitiesChooser

public CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser)
Description copied from interface: Window
Set the CapabilitiesChooser to help determine the native visual type.

Specified by:
setCapabilitiesChooser in interface Window
Parameters:
chooser - the new CapabilitiesChooser
Returns:
the previous CapabilitiesChooser

getChosenCapabilities

public final CapabilitiesImmutable getChosenCapabilities()
Description copied from interface: Window
Gets an immutable set of chosen capabilities.

Specified by:
getChosenCapabilities in interface Window
Returns:
the chosen capabilities

getRequestedCapabilities

public final CapabilitiesImmutable getRequestedCapabilities()
Description copied from interface: Window
Gets an immutable set of requested capabilities.

Specified by:
getRequestedCapabilities in interface Window
Returns:
the requested capabilities

getWindow

public final Window getWindow()

getParent

public final NativeWindow getParent()
Specified by:
getParent in interface NativeWindow
Returns:
The parent NativeWindow, or null if this NativeWindow is top level.

getScreen

public final Screen getScreen()
Specified by:
getScreen in interface Window
Returns:
The associated Screen

setTitle

public final void setTitle(String title)
Specified by:
setTitle in interface Window

getTitle

public final String getTitle()
Specified by:
getTitle in interface Window

setUndecorated

public final void setUndecorated(boolean value)
Specified by:
setUndecorated in interface Window

isUndecorated

public final boolean isUndecorated()
Specified by:
isUndecorated in interface Window

setAlwaysOnTop

public final void setAlwaysOnTop(boolean value)
Specified by:
setAlwaysOnTop in interface Window

isAlwaysOnTop

public final boolean isAlwaysOnTop()
Specified by:
isAlwaysOnTop in interface Window

setFocusAction

public final void setFocusAction(Window.FocusRunnable focusAction)
Description copied from interface: Window
May set to a Window.FocusRunnable, Window.FocusRunnable.run() before Newt requests the native focus. This allows notifying a covered window toolkit like AWT that the focus is requested, hence focus traversal can be made transparent.

Specified by:
setFocusAction in interface Window

requestFocus

public final void requestFocus()
Specified by:
requestFocus in interface Window

hasFocus

public boolean hasFocus()
Specified by:
hasFocus in interface Window

getInsets

public final InsetsImmutable getInsets()
Description copied from interface: NativeWindow
Returns the insets defined as the width and height of the window decoration on the left, right, top and bottom.
Insets are zero if the window is undecorated, including child windows.

Insets are available only after the native window has been created, ie. the native window has been made visible.
The top-level window area's top-left corner is located at

   getX() - getInsets().getLeftWidth()
   getY() - getInsets().getTopHeight()
 
The top-level window size is
   getWidth()  + getInsets().getTotalWidth() 
   getHeight() + getInsets().getTotalHeight()
 

Specified by:
getInsets in interface NativeWindow
Returns:
insets

setPosition

public final void setPosition(int x,
                              int y)
Description copied from interface: Window
Sets the location of the window's client area, excluding insets (window decorations).
This call is ignored if in fullscreen mode.

Specified by:
setPosition in interface Window
Parameters:
x - coord of the client-area's top left corner
y - coord of the client-area's top left corner
See Also:
NativeWindow.getInsets()

setTopLevelPosition

public void setTopLevelPosition(int x,
                                int y)
Description copied from interface: Window
Sets the location of the top-level window inclusive insets (window decorations).

Note: Insets (if supported) are available only after the window is set visible and hence has been created.

This call is ignored if in fullscreen mode.

Specified by:
setTopLevelPosition in interface Window
Parameters:
x - coord of the top-level left corner
y - coord of the top-level left corner
See Also:
Window.setPosition(int, int), NativeWindow.getInsets()

setFullscreen

public final boolean setFullscreen(boolean fullscreen)
Specified by:
setFullscreen in interface Window

isFullscreen

public final boolean isFullscreen()
Specified by:
isFullscreen in interface Window

isVisible

public final boolean isVisible()
Specified by:
isVisible in interface Window

toString

public final String toString()
Specified by:
toString in interface GLDrawable
Overrides:
toString in class Object

reparentWindow

public final int reparentWindow(NativeWindow newParent)
Description copied from interface: Window
Change this window's parent window.

In case the old parent is not null and a Window, this window is removed from it's list of children.
In case the new parent is not null and a Window, this window is added to it's list of children.

Specified by:
reparentWindow in interface Window
Parameters:
newParent - The new parent NativeWindow. If null, this Window becomes a top level window.
Returns:
The issued reparent action type (strategy) as defined in Window.ReparentAction

reparentWindow

public final int reparentWindow(NativeWindow newParent,
                                boolean forceDestroyCreate)
Specified by:
reparentWindow in interface Window

removeChild

public final boolean removeChild(NativeWindow win)
Specified by:
removeChild in interface Window

addChild

public final boolean addChild(NativeWindow win)
Specified by:
addChild in interface Window

destroy

public final void destroy()
Description copied from interface: GLAutoDrawable
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 dispose(..) for all registered GLEventListeners. Called automatically by the window system toolkit upon receiving a destroy notification. This routine may be called manually.

Specified by:
destroy in interface Window
Specified by:
destroy in interface NativeWindow
Specified by:
destroy in interface GLAutoDrawable
See Also:
Window.destroy(), Window.setVisible(boolean)

setVisible

public final void setVisible(boolean visible)
Description copied from interface: Window

setVisible makes the window and children visible if visible is true, otherwise the window and children becomes invisible.

The setVisible(true) is responsible to actual create the native window.

Zero size semantics are respected, see Window.setSize(int,int):

 if ( 0 == windowHandle && visible ) {
   this.visible = visible;
   if( 0 < width*height ) {
     createNative();
   }
 } else if ( this.visible != visible ) {
   this.visible = visible;
   setNativeSizeImpl();
 }
 

In case this window is a child window and a parent NativeWindow is being used,
the parent's NativeWindow handle is retrieved via NativeWindow.getWindowHandle().
If this action fails, ie if the parent NativeWindow is not valid yet,
no native window is created yet and setVisible(true) shall be repeated when it is.

Specified by:
setVisible in interface Window

setSize

public final void setSize(int width,
                          int height)
Description copied from interface: Window
Sets the size of the window's client area, excluding decorations.

Zero size semantics are respected, see Window.setVisible(boolean):

 if ( 0 != windowHandle && 0 ≥ width*height && visible ) {
   setVisible(false);
 } else if ( 0 == windowHandle && 0 < width*height && visible ) {
   setVisible(true);
 } else {
   // as expected ..
 }
 

This call is ignored if in fullscreen mode.

Specified by:
setSize in interface Window
Parameters:
width - of the window's client area
height - of the window's client area
See Also:
NativeWindow.getInsets()

setTopLevelSize

public void setTopLevelSize(int width,
                            int height)
Description copied from interface: Window
Sets the size of the top-level window including insets (window decorations).

Note: Insets (if supported) are available only after the window is set visible and hence has been created.

Specified by:
setTopLevelSize in interface Window
Parameters:
width - of the top-level window area
height - of the top-level window area
See Also:
Window.setSize(int, int), NativeWindow.getInsets()

isNativeValid

public final boolean isNativeValid()
Specified by:
isNativeValid in interface Window
Returns:
true if the native window handle is valid and ready to operate, ie if the native window has been created via setVisible(true), otherwise false.
See Also:
Window.setVisible(boolean), #destroy(boolean)

getLocationOnScreen

public Point getLocationOnScreen(Point storage)
Description copied from interface: NativeWindow
Returns the current absolute location of this window.

Specified by:
getLocationOnScreen in interface NativeWindow
Parameters:
storage - if not null, Point.translate(javax.media.nativewindow.util.Point) the passed Point by this location on the screen and return it.
Returns:
either the passed non null translated point by the screen location of this NativeWindow, or a new instance with the screen location of this NativeWindow.

getFactory

public GLDrawableFactory getFactory()
Specified by:
getFactory in interface GLDrawable

setSharedContext

public void setSharedContext(GLContext sharedContext)
Specifies an OpenGL context to share with.
At native creation, setVisible(true), a drawable and context is created besides the native Window itself,
hence you shall set the shared context before.

Parameters:
sharedContext - The OpenGL context shared by this GLWindow's one

setContext

public void setContext(GLContext newCtx)
Description copied from interface: GLAutoDrawable
Associate a new context to this drawable.

Specified by:
setContext in interface GLAutoDrawable

getContext

public GLContext getContext()
Description copied from interface: GLAutoDrawable
Returns the context associated with this drawable. The returned context will be synchronized. Don't rely on it's identity, the context may change.

Specified by:
getContext in interface GLAutoDrawable

getGL

public GL getGL()
Description copied from interface: GLAutoDrawable
Returns the GL pipeline object this GLAutoDrawable uses. If this method is called outside of the GLEventListener's callback methods (init, display, etc.) it may return null. Users should not rely on the identity of the returned GL object; for example, users should not maintain a hash table with the GL object as the key. Additionally, the GL object should not be cached in client code, but should be re-fetched from the GLAutoDrawable at the beginning of each call to init, display, etc.

Specified by:
getGL in interface GLAutoDrawable

setGL

public GL setGL(GL gl)
Description copied from interface: GLAutoDrawable
Sets the GL pipeline object this GLAutoDrawable uses. This should only be called from within the GLEventListener's callback methods, and usually only from within the init() method, in order to install a composable pipeline. See the JOGL demos for examples.

Specified by:
setGL in interface GLAutoDrawable
Returns:
the set GL pipeline or null if not successful

addGLEventListener

public void addGLEventListener(GLEventListener listener)
Description copied from interface: GLAutoDrawable
Adds a GLEventListener to the end of this drawable queue. The listeners are notified of events in the order of the queue.

Specified by:
addGLEventListener in interface GLAutoDrawable

addGLEventListener

public void addGLEventListener(int index,
                               GLEventListener listener)
Description copied from interface: GLAutoDrawable
Adds a GLEventListener at the given index of this drawable queue. The listeners are notified of events in the order of the queue.

Specified by:
addGLEventListener in interface GLAutoDrawable
Parameters:
index - 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().
listener - The GLEventListener object to be inserted

removeGLEventListener

public void removeGLEventListener(GLEventListener listener)
Description copied from interface: GLAutoDrawable
Removes a GLEventListener from this drawable. Note that if this is done from within a particular drawable's GLEventListener handler (reshape, display, etc.) that it is not guaranteed that all other listeners will be evaluated properly during this update cycle.

Specified by:
removeGLEventListener in interface GLAutoDrawable

setAnimator

public void setAnimator(GLAnimatorControl animatorControl)
Description copied from interface: GLAutoDrawable

Registers the usage of an animator, an GLAnimatorControl implementation. The animator will be queried whether it's animating, ie periodically issuing GLAutoDrawable.display() calls or not.


This method shall be called by an animator implementation only,
e.g. AnimatorBase.add(javax.media.opengl.GLAutoDrawable), passing it's control implementation,
and AnimatorBase.remove(javax.media.opengl.GLAutoDrawable), passing null.


Impacts GLAutoDrawable.display() and GLAutoDrawable.invoke(boolean, GLRunnable) semantics.


Specified by:
setAnimator in interface GLAutoDrawable
See Also:
GLAutoDrawable.display(), GLAutoDrawable.invoke(boolean, GLRunnable), GLAnimatorControl

getAnimator

public GLAnimatorControl getAnimator()
Specified by:
getAnimator in interface GLAutoDrawable
Returns:
the registered GLAnimatorControl implementation, using this GLAutoDrawable.
See Also:
GLAutoDrawable.setAnimator(javax.media.opengl.GLAnimatorControl), GLAnimatorControl

invoke

public void invoke(boolean wait,
                   GLRunnable glRunnable)
Description copied from interface: GLAutoDrawable

Enqueues a one-shot GLRunnable, which will be executed with the next GLAutoDrawable.display() call.

If no GLAnimatorControl is registered, or if it is not animating, the default situation,
or if the current thread is the animator thread,
a GLAutoDrawable.display() call is issued after enqueue the GLRunnable.
No extra synchronization is performed in case wait is true, since it is executed in the current thread.

If GLAnimatorControl is registered and is animating,
no GLAutoDrawable.display() call is issued, since the animator thread performs it.
If wait is true, the implementation waits until the GLRunnable is executed.


Specified by:
invoke in interface GLAutoDrawable
See Also:
GLAutoDrawable.setAnimator(javax.media.opengl.GLAnimatorControl), GLAutoDrawable.display(), GLRunnable

display

public void display()
Description copied from interface: GLAutoDrawable

Causes OpenGL rendering to be performed for this GLAutoDrawable in the following order:

May be called periodically by a running GLAnimatorControl implementation,
which must register itself with GLAutoDrawable.setAnimator(javax.media.opengl.GLAnimatorControl).

Called automatically by the window system toolkit upon receiving a repaint() request,
except an GLAnimatorControl implementation GLAnimatorControl.isAnimating().

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 display(..) callback.

In case of a new generated OpenGL context, the implementation shall call init(..) for all registered GLEventListeners before making the actual display(..) calls, in case this has not been done yet.

Specified by:
display in interface GLAutoDrawable
See Also:
GLAutoDrawable.setAnimator(javax.media.opengl.GLAnimatorControl)

setAutoSwapBufferMode

public void setAutoSwapBufferMode(boolean onOrOff)
This implementation uses a static value

Specified by:
setAutoSwapBufferMode in interface GLAutoDrawable

getAutoSwapBufferMode

public boolean getAutoSwapBufferMode()
This implementation uses a static value

Specified by:
getAutoSwapBufferMode in interface GLAutoDrawable

swapBuffers

public void swapBuffers()
Description copied from interface: GLDrawable
Swaps the front and back buffers of this drawable. For GLAutoDrawable implementations, when automatic buffer swapping is enabled (as is the default), this method is called automatically and should not be called by the end user.

Specified by:
swapBuffers in interface GLDrawable

setContextCreationFlags

public void setContextCreationFlags(int flags)
Specified by:
setContextCreationFlags in interface GLAutoDrawable
Parameters:
flags - Additional context creation flags.
See Also:
GLContext.setContextCreationFlags(int), GLContext.enableGLDebugMessage(boolean)

getContextCreationFlags

public int getContextCreationFlags()
Specified by:
getContextCreationFlags in interface GLAutoDrawable
Returns:
Additional context creation flags

setUpdateFPSFrames

public final void setUpdateFPSFrames(int frames,
                                     PrintStream out)
Specified by:
setUpdateFPSFrames in interface FPSCounter
Parameters:
frames - Update interval in frames.
At every rendered frames interval the currentTime and fps values are updated. If the frames interval is <= 0, no update will be issued, ie the FPSCounter feature is turned off. You may choose FPSCounter.DEFAULT_FRAMES_PER_INTERVAL.
out - optional print stream where the fps values gets printed if not null at every frames interval

resetFPSCounter

public final void resetFPSCounter()
Description copied from interface: FPSCounter
Reset all performance counter (startTime, currentTime, frame number)

Specified by:
resetFPSCounter in interface FPSCounter

getUpdateFPSFrames

public final int getUpdateFPSFrames()
Specified by:
getUpdateFPSFrames in interface FPSCounter
Returns:
update interval in frames
See Also:
FPSCounter.setUpdateFPSFrames(int, PrintStream)

getFPSStartTime

public final long getFPSStartTime()
Description copied from interface: FPSCounter
Returns the time of the first display call in milliseconds after enabling this feature via FPSCounter.setUpdateFPSFrames(int, PrintStream).
This value is reset via FPSCounter.resetFPSCounter().

Specified by:
getFPSStartTime in interface FPSCounter
See Also:
FPSCounter.setUpdateFPSFrames(int, PrintStream), FPSCounter.resetFPSCounter()

getLastFPSUpdateTime

public final long getLastFPSUpdateTime()
Description copied from interface: FPSCounter
Returns the time of the last update interval in milliseconds, if this feature is enabled via FPSCounter.setUpdateFPSFrames(int, PrintStream).
This value is reset via FPSCounter.resetFPSCounter().

Specified by:
getLastFPSUpdateTime in interface FPSCounter
See Also:
FPSCounter.setUpdateFPSFrames(int, PrintStream), FPSCounter.resetFPSCounter()

getLastFPSPeriod

public final long getLastFPSPeriod()
Specified by:
getLastFPSPeriod in interface FPSCounter
Returns:
Duration of the last update interval in milliseconds.
See Also:
FPSCounter.setUpdateFPSFrames(int, PrintStream), FPSCounter.resetFPSCounter()

getLastFPS

public final float getLastFPS()
Specified by:
getLastFPS in interface FPSCounter
Returns:
Last update interval's frames per seconds, FPSCounter.getUpdateFPSFrames() / FPSCounter.getLastFPSPeriod()
See Also:
FPSCounter.setUpdateFPSFrames(int, PrintStream), FPSCounter.resetFPSCounter()

getTotalFPSFrames

public final int getTotalFPSFrames()
Specified by:
getTotalFPSFrames in interface FPSCounter
Returns:
Number of frame rendered since FPSCounter.getFPSStartTime() up to FPSCounter.getLastFPSUpdateTime()
See Also:
FPSCounter.setUpdateFPSFrames(int, PrintStream), FPSCounter.resetFPSCounter()

getTotalFPSDuration

public final long getTotalFPSDuration()
Specified by:
getTotalFPSDuration in interface FPSCounter
Returns:
Total duration in milliseconds, FPSCounter.getLastFPSUpdateTime() - FPSCounter.getFPSStartTime()
See Also:
FPSCounter.setUpdateFPSFrames(int, PrintStream), FPSCounter.resetFPSCounter()

getTotalFPS

public final float getTotalFPS()
Specified by:
getTotalFPS in interface FPSCounter
Returns:
Total frames per seconds, FPSCounter.getTotalFPSFrames() / FPSCounter.getTotalFPSDuration()
See Also:
FPSCounter.setUpdateFPSFrames(int, PrintStream), FPSCounter.resetFPSCounter()

getNativeSurface

public final NativeSurface getNativeSurface()
Specified by:
getNativeSurface in interface GLDrawable

getHandle

public final long getHandle()
Description copied from interface: GLDrawable
This is the GL/Windowing drawable handle.
It is usually the NativeSurface.getSurfaceHandle(), ie the native surface handle of the underlying windowing toolkit.
However, on X11/GLX this reflects a GLXDrawable, which represents a GLXWindow, GLXPixmap, or GLXPbuffer.
On EGL, this represents the EGLSurface.

Specified by:
getHandle in interface GLDrawable

getX

public final int getX()
Specified by:
getX in interface NativeWindow
Returns:
the current x position of the top-left corner of the client area, hence excluding insets (window decorations).
See Also:
NativeWindow.getInsets()

getY

public final int getY()
Specified by:
getY in interface NativeWindow
Returns:
the current y position of the top-left corner of the client area, hence excluding insets (window decorations).
See Also:
NativeWindow.getInsets()

getWidth

public final int getWidth()
Description copied from interface: GLDrawable
Returns the current width of this GLDrawable.

Specified by:
getWidth in interface NativeSurface
Specified by:
getWidth in interface GLDrawable
Returns:
width of the client area

getHeight

public final int getHeight()
Description copied from interface: GLDrawable
Returns the current height of this GLDrawable.

Specified by:
getHeight in interface NativeSurface
Specified by:
getHeight in interface GLDrawable
Returns:
height of the client area

createContext

public final GLContext createContext(GLContext shareWith)
Description copied from interface: GLDrawable
Creates a new context for drawing to this drawable that will optionally share display lists and other server-side OpenGL objects with the specified GLContext.

The GLContext share need not be associated with this GLDrawable and may be null if sharing of display lists and other objects is not desired. See the note in the overview documentation on context sharing.

Specified by:
createContext in interface GLDrawable

setRealized

public final void setRealized(boolean realized)
Description copied from interface: GLDrawable
Indicates to on-screen GLDrawable implementations whether the underlying window has been created and can be drawn into. End users do not need to call this method; it is not necessary to call setRealized on a GLCanvas, a GLJPanel, or a GLPbuffer, as these perform the appropriate calls on their underlying GLDrawables internally.

Developers implementing new OpenGL components for various window toolkits need to call this method against GLDrawables obtained from the GLDrawableFactory via the GLDrawableFactory.getGLDrawable() method. It must typically be called with an argument of true when the component associated with the GLDrawable is realized and with an argument of false just before the component is unrealized. For the AWT, this means calling setRealized(true) in the addNotify method and with an argument of false in the removeNotify method.

GLDrawable implementations should handle multiple cycles of setRealized(true) / setRealized(false) calls. Most, if not all, Java window toolkits have a persistent object associated with a given component, regardless of whether that component is currently realized. The GLDrawable object associated with a particular component is intended to be similarly persistent. A GLDrawable is intended to be created for a given component when it is constructed and live as long as that component. setRealized allows the GLDrawable to re-initialize and destroy any associated resources as the component becomes realized and unrealized, respectively.

With an argument of true, the minimum implementation shall call NativeSurface's lockSurface() and if successfull:


This is important since NativeSurface's lockSurface() ensures resolving the window/surface handles, and the drawable's GLCapabilities might have changed.

Calling this method has no other effects. For example, if removeNotify is called on a Canvas implementation for which a GLDrawable has been created, it is also necessary to destroy all OpenGL contexts associated with that GLDrawable. This is not done automatically by the implementation.

Specified by:
setRealized in interface GLDrawable

isRealized

public final boolean isRealized()
Specified by:
isRealized in interface GLDrawable
Returns:
true if this drawable is realized, otherwise false

getChosenGLCapabilities

public final GLCapabilitiesImmutable getChosenGLCapabilities()
Description copied from interface: GLDrawable
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.
On some platforms, the pixel format is not directly associated with the drawable; a best attempt is made to return a reasonable value in this case.
This object shall be directly associated to the attached NativeSurface's AbstractGraphicsConfiguration, and if changes are necessary, they should reflect those as well.

Specified by:
getChosenGLCapabilities in interface GLDrawable
Returns:
A copy of the queried object.

getGLProfile

public final GLProfile getGLProfile()
Description copied from interface: GLDrawable
Fetches the GLProfile for this drawable. Returns the GLProfile object, no copy.

Specified by:
getGLProfile in interface GLDrawable

consumeEvent

public boolean consumeEvent(NEWTEvent event)
Description copied from interface: NEWTEventConsumer
Consume the event

Specified by:
consumeEvent in interface NEWTEventConsumer
Returns:
true if the event has been consumed, otherwise it returns false for later propagation.

windowRepaint

public final void windowRepaint(int x,
                                int y,
                                int width,
                                int height)
Specified by:
windowRepaint in interface Window

enqueueEvent

public final void enqueueEvent(boolean wait,
                               NEWTEvent event)
Specified by:
enqueueEvent in interface Window

runOnEDTIfAvail

public final void runOnEDTIfAvail(boolean wait,
                                  Runnable task)
Specified by:
runOnEDTIfAvail in interface Window

getSurfaceUpdatedListener

public final SurfaceUpdatedListener getSurfaceUpdatedListener(int index)
Specified by:
getSurfaceUpdatedListener in interface Window

getSurfaceUpdatedListeners

public final SurfaceUpdatedListener[] getSurfaceUpdatedListeners()
Specified by:
getSurfaceUpdatedListeners in interface Window

removeAllSurfaceUpdatedListener

public final void removeAllSurfaceUpdatedListener()
Specified by:
removeAllSurfaceUpdatedListener in interface Window

removeSurfaceUpdatedListener

public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
Specified by:
removeSurfaceUpdatedListener in interface Window

addSurfaceUpdatedListener

public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l)
Description copied from interface: Window
Appends the given com.jogamp.newt.event.SurfaceUpdatedListener to the end of the list.

Specified by:
addSurfaceUpdatedListener in interface Window

addSurfaceUpdatedListener

public final void addSurfaceUpdatedListener(int index,
                                            SurfaceUpdatedListener l)
                                     throws IndexOutOfBoundsException
Description copied from interface: Window
Inserts the given com.jogamp.newt.event.SurfaceUpdatedListener at the specified position in the list.

Specified by:
addSurfaceUpdatedListener in interface Window
Parameters:
index - 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().
l - The listener object to be inserted
Throws:
IndexOutOfBoundsException - If the index is not within (0 <= index && index <= size()), or -1

sendWindowEvent

public void sendWindowEvent(int eventType)
Specified by:
sendWindowEvent in interface Window

getWindowListener

public final WindowListener getWindowListener(int index)
Specified by:
getWindowListener in interface Window

getWindowListeners

public final WindowListener[] getWindowListeners()
Specified by:
getWindowListeners in interface Window

removeWindowListener

public final void removeWindowListener(WindowListener l)
Specified by:
removeWindowListener in interface Window

addWindowListener

public final void addWindowListener(WindowListener l)
Description copied from interface: Window
Appends the given WindowListener to the end of the list.

Specified by:
addWindowListener in interface Window

addWindowListener

public final void addWindowListener(int index,
                                    WindowListener l)
                             throws IndexOutOfBoundsException
Description copied from interface: Window
Inserts the given WindowListener at the specified position in the list.

Specified by:
addWindowListener in interface Window
Parameters:
index - 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().
l - The listener object to be inserted
Throws:
IndexOutOfBoundsException - If the index is not within (0 <= index && index <= size()), or -1

addKeyListener

public final void addKeyListener(KeyListener l)
Description copied from interface: Window
Appends the given KeyListener to the end of the list.

Specified by:
addKeyListener in interface Window

addKeyListener

public final void addKeyListener(int index,
                                 KeyListener l)
Description copied from interface: Window
Inserts the given KeyListener at the specified position in the list.

Specified by:
addKeyListener in interface Window
Parameters:
index - 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().
l - The listener object to be inserted

removeKeyListener

public final void removeKeyListener(KeyListener l)
Specified by:
removeKeyListener in interface Window

getKeyListener

public final KeyListener getKeyListener(int index)
Specified by:
getKeyListener in interface Window

getKeyListeners

public final KeyListener[] getKeyListeners()
Specified by:
getKeyListeners in interface Window

addMouseListener

public final void addMouseListener(MouseListener l)
Description copied from interface: Window
Appends the given MouseListener to the end of the list.

Specified by:
addMouseListener in interface Window

addMouseListener

public final void addMouseListener(int index,
                                   MouseListener l)
Description copied from interface: Window
Inserts the given MouseListener at the specified position in the list.

Specified by:
addMouseListener in interface Window
Parameters:
index - 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().
l - The listener object to be inserted

removeMouseListener

public final void removeMouseListener(MouseListener l)
Specified by:
removeMouseListener in interface Window

getMouseListener

public final MouseListener getMouseListener(int index)
Specified by:
getMouseListener in interface Window

getMouseListeners

public final MouseListener[] getMouseListeners()
Specified by:
getMouseListeners in interface Window

lockSurface

public final int lockSurface()
Description copied from interface: NativeSurface
Lock the surface of this native window

The surface handle, see NativeSurface.lockSurface(),
shall be valid after a successfull call, ie return a value other than NativeSurface.LOCK_SURFACE_NOT_READY.

This call is blocking until the surface has been locked or a timeout is reached. The latter will throw a runtime exception.

This call allows recursion from the same thread.

The implementation may want to aquire the application level RecursiveLock first before proceeding with a native surface lock.

The implementation shall also invoke AbstractGraphicsDevice.lock() for the initial lock (recursive count zero).

Specified by:
lockSurface in interface NativeSurface
Returns:
NativeSurface.LOCK_SUCCESS, NativeSurface.LOCK_SURFACE_CHANGED or NativeSurface.LOCK_SURFACE_NOT_READY.
See Also:
RecursiveLock

unlockSurface

public final void unlockSurface()
                         throws NativeWindowException
Description copied from interface: NativeSurface
Unlock the surface of this native window Shall not modify the surface handle, see NativeSurface.lockSurface()

The implementation shall also invoke AbstractGraphicsDevice.unlock() for the final unlock (recursive count zero).

Specified by:
unlockSurface in interface NativeSurface
Throws:
NativeWindowException
See Also:
NativeSurface.lockSurface(), RecursiveLock

isSurfaceLockedByOtherThread

public final boolean isSurfaceLockedByOtherThread()
Description copied from interface: NativeSurface
Return if surface is locked by another thread, ie not the current one

Specified by:
isSurfaceLockedByOtherThread in interface NativeSurface

isSurfaceLocked

public final boolean isSurfaceLocked()
Description copied from interface: NativeSurface
Return if surface is locked

Specified by:
isSurfaceLocked in interface NativeSurface

getSurfaceLockOwner

public final Thread getSurfaceLockOwner()
Description copied from interface: NativeSurface
Return the locking owner's Thread, or null if not locked.

Specified by:
getSurfaceLockOwner in interface NativeSurface

surfaceSwap

public final boolean surfaceSwap()
Description copied from interface: NativeSurface
Provide a mechanism to utilize custom (pre-) swap surface code. This method is called before the render toolkit (e.g. JOGL) swaps the buffer/surface. The implementation may itself apply the swapping, in which case true shall be returned.

Specified by:
surfaceSwap in interface NativeSurface
Returns:
true if this method completed swapping the surface, otherwise false, in which case eg the GLDrawable implementation has to swap the code.

getWindowHandle

public final long getWindowHandle()
Description copied from interface: NativeWindow
Returns the window handle for this NativeWindow.

The window handle shall reflect the platform one for all window related operations, e.g. open, close, resize.

On X11 this returns an entity of type Window.
On Microsoft Windows this returns an entity of type HWND.

Specified by:
getWindowHandle in interface NativeWindow

getSurfaceHandle

public final long getSurfaceHandle()
Description copied from interface: NativeSurface
Returns the handle to the surface for this NativeSurface.

The surface handle should be set/update by NativeSurface.lockSurface(), where NativeSurface.unlockSurface() is not allowed to modify it. After NativeSurface.unlockSurface() it is no more guaranteed that the surface handle is still valid. The surface handle shall reflect the platform one for all drawable surface operations, e.g. opengl, swap-buffer.

On X11 this returns an entity of type Window, since there is no differentiation of surface and window there.
On Microsoft Windows this returns an entity of type HDC.

Specified by:
getSurfaceHandle in interface NativeSurface

getGraphicsConfiguration

public final AbstractGraphicsConfiguration getGraphicsConfiguration()
Description copied from interface: NativeSurface
Returns the graphics configuration corresponding to this window.

Specified by:
getGraphicsConfiguration in interface NativeSurface
See Also:
javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)

getDisplayHandle

public final long getDisplayHandle()
Description copied from interface: NativeSurface
Convenience: Get display handle from AbstractGraphicsConfiguration . AbstractGraphicsScreen . AbstractGraphicsDevice

Specified by:
getDisplayHandle in interface NativeSurface

getScreenIndex

public final int getScreenIndex()
Description copied from interface: NativeSurface
Convenience: Get display handle from AbstractGraphicsConfiguration . AbstractGraphicsScreen

Specified by:
getScreenIndex in interface NativeSurface

surfaceUpdated

public final void surfaceUpdated(Object updater,
                                 NativeSurface ns,
                                 long when)
Description copied from interface: SurfaceUpdatedListener
Notification of a surface update event.

Specified by:
surfaceUpdated in interface SurfaceUpdatedListener
Parameters:
updater - is the caller object who updated the surface, e.g. a JOGL GLDrawable.
ns - the updated NativeSurface
when - the time in ms, when the surface was updated

main

public static void main(String[] args)
A most simple JOGL AWT test entry



Copyright 2010 JogAmp Community.