|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jogamp.newt.opengl.GLWindow
public class GLWindow
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 GLEventListener s. |
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 |
---|
public static GLWindow create(GLCapabilitiesImmutable caps)
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.
public static GLWindow create(Screen screen, GLCapabilitiesImmutable caps)
The resulting GLWindow owns the Window, ie it will be destructed.
public static GLWindow create(Window window)
The resulting GLWindow does not own the given Window, ie it will not be destructed.
public static GLWindow create(NativeWindow parentNativeWindow, GLCapabilitiesImmutable caps)
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.
public int getDefaultCloseOperation()
getDefaultCloseOperation
in interface WindowClosingProtocol
WindowClosingProtocol.DISPOSE_ON_CLOSE
,
WindowClosingProtocol.DO_NOTHING_ON_CLOSE
public int setDefaultCloseOperation(int op)
setDefaultCloseOperation
in interface WindowClosingProtocol
op
- the new close operation value
WindowClosingProtocol.DISPOSE_ON_CLOSE
,
WindowClosingProtocol.DO_NOTHING_ON_CLOSE
public CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser)
Window
setCapabilitiesChooser
in interface Window
chooser
- the new CapabilitiesChooser
public final CapabilitiesImmutable getChosenCapabilities()
Window
getChosenCapabilities
in interface Window
public final CapabilitiesImmutable getRequestedCapabilities()
Window
getRequestedCapabilities
in interface Window
public final Window getWindow()
public final NativeWindow getParent()
getParent
in interface NativeWindow
public final Screen getScreen()
getScreen
in interface Window
public final void setTitle(String title)
setTitle
in interface Window
public final String getTitle()
getTitle
in interface Window
public final void setUndecorated(boolean value)
setUndecorated
in interface Window
public final boolean isUndecorated()
isUndecorated
in interface Window
public final void setAlwaysOnTop(boolean value)
setAlwaysOnTop
in interface Window
public final boolean isAlwaysOnTop()
isAlwaysOnTop
in interface Window
public final void setFocusAction(Window.FocusRunnable focusAction)
Window
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.
setFocusAction
in interface Window
public final void requestFocus()
requestFocus
in interface Window
public boolean hasFocus()
hasFocus
in interface Window
public final InsetsImmutable getInsets()
NativeWindow
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().The top-level window size isgetLeftWidth()
getY() - getInsets().getTopHeight()
getWidth() + getInsets().getTotalWidth()
getHeight() + getInsets().getTotalHeight()
getInsets
in interface NativeWindow
public final void setPosition(int x, int y)
Window
setPosition
in interface Window
x
- coord of the client-area's top left cornery
- coord of the client-area's top left cornerNativeWindow.getInsets()
public void setTopLevelPosition(int x, int y)
Window
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.
setTopLevelPosition
in interface Window
x
- coord of the top-level left cornery
- coord of the top-level left cornerWindow.setPosition(int, int)
,
NativeWindow.getInsets()
public final boolean setFullscreen(boolean fullscreen)
setFullscreen
in interface Window
public final boolean isFullscreen()
isFullscreen
in interface Window
public final boolean isVisible()
isVisible
in interface Window
public final String toString()
toString
in interface GLDrawable
toString
in class Object
public final int reparentWindow(NativeWindow newParent)
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.
reparentWindow
in interface Window
newParent
- The new parent NativeWindow. If null, this Window becomes a top level window.
public final int reparentWindow(NativeWindow newParent, boolean forceDestroyCreate)
reparentWindow
in interface Window
public final boolean removeChild(NativeWindow win)
removeChild
in interface Window
public final boolean addChild(NativeWindow win)
addChild
in interface Window
public final void destroy()
GLAutoDrawable
dispose(..)
for all
registered GLEventListener
s. Called automatically by the
window system toolkit upon receiving a destroy notification. This
routine may be called manually.
destroy
in interface Window
destroy
in interface NativeWindow
destroy
in interface GLAutoDrawable
Window.destroy()
,
Window.setVisible(boolean)
public final void setVisible(boolean visible)
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.
setVisible
in interface Window
public final void setSize(int width, int height)
Window
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.
setSize
in interface Window
width
- of the window's client areaheight
- of the window's client areaNativeWindow.getInsets()
public void setTopLevelSize(int width, int height)
Window
Note: Insets (if supported) are available only after the window is set visible and hence has been created.
setTopLevelSize
in interface Window
width
- of the top-level window areaheight
- of the top-level window areaWindow.setSize(int, int)
,
NativeWindow.getInsets()
public final boolean isNativeValid()
isNativeValid
in interface Window
setVisible(true)
, otherwise false.Window.setVisible(boolean)
,
#destroy(boolean)
public Point getLocationOnScreen(Point storage)
NativeWindow
getLocationOnScreen
in interface NativeWindow
storage
- if not null,
Point.translate(javax.media.nativewindow.util.Point)
the passed Point
by this location on the screen and return it.
public GLDrawableFactory getFactory()
getFactory
in interface GLDrawable
public void setSharedContext(GLContext sharedContext)
OpenGL context
to share with.setVisible(true)
,
a drawable
and context
is created besides the native Window itself,
sharedContext
- The OpenGL context shared by this GLWindow's onepublic void setContext(GLContext newCtx)
GLAutoDrawable
setContext
in interface GLAutoDrawable
public GLContext getContext()
GLAutoDrawable
getContext
in interface GLAutoDrawable
public GL getGL()
GLAutoDrawable
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.
getGL
in interface GLAutoDrawable
public GL setGL(GL gl)
GLAutoDrawable
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.
setGL
in interface GLAutoDrawable
public void addGLEventListener(GLEventListener listener)
GLAutoDrawable
GLEventListener
to the end of this drawable queue.
The listeners are notified of events in the order of the queue.
addGLEventListener
in interface GLAutoDrawable
public void addGLEventListener(int index, GLEventListener listener)
GLAutoDrawable
GLEventListener
at the given index of this drawable queue.
The listeners are notified of events in the order of the queue.
addGLEventListener
in interface GLAutoDrawable
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 insertedpublic void removeGLEventListener(GLEventListener listener)
GLAutoDrawable
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.
removeGLEventListener
in interface GLAutoDrawable
public void setAnimator(GLAnimatorControl animatorControl)
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.
setAnimator
in interface GLAutoDrawable
GLAutoDrawable.display()
,
GLAutoDrawable.invoke(boolean, GLRunnable)
,
GLAnimatorControl
public GLAnimatorControl getAnimator()
getAnimator
in interface GLAutoDrawable
GLAnimatorControl
implementation, using this GLAutoDrawable
.GLAutoDrawable.setAnimator(javax.media.opengl.GLAnimatorControl)
,
GLAnimatorControl
public void invoke(boolean wait, GLRunnable glRunnable)
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.
invoke
in interface GLAutoDrawable
GLAutoDrawable.setAnimator(javax.media.opengl.GLAnimatorControl)
,
GLAutoDrawable.display()
,
GLRunnable
public void display()
GLAutoDrawable
Causes OpenGL rendering to be performed for this GLAutoDrawable in the following order:
display(..)
for all
registered GLEventListener
s. GLRunnable
,
enqueued via GLAutoDrawable.invoke(boolean, GLRunnable)
.
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 GLEventListener
s before making the
actual display(..)
calls,
in case this has not been done yet.
display
in interface GLAutoDrawable
GLAutoDrawable.setAnimator(javax.media.opengl.GLAnimatorControl)
public void setAutoSwapBufferMode(boolean onOrOff)
setAutoSwapBufferMode
in interface GLAutoDrawable
public boolean getAutoSwapBufferMode()
getAutoSwapBufferMode
in interface GLAutoDrawable
public void swapBuffers()
GLDrawable
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.
swapBuffers
in interface GLDrawable
public void setContextCreationFlags(int flags)
setContextCreationFlags
in interface GLAutoDrawable
flags
- Additional context creation flags.GLContext.setContextCreationFlags(int)
,
GLContext.enableGLDebugMessage(boolean)
public int getContextCreationFlags()
getContextCreationFlags
in interface GLAutoDrawable
public final void setUpdateFPSFrames(int frames, PrintStream out)
setUpdateFPSFrames
in interface FPSCounter
frames
- Update interval in frames.FPSCounter.DEFAULT_FRAMES_PER_INTERVAL
.out
- optional print stream where the fps values gets printed if not null at every frames intervalpublic final void resetFPSCounter()
FPSCounter
resetFPSCounter
in interface FPSCounter
public final int getUpdateFPSFrames()
getUpdateFPSFrames
in interface FPSCounter
FPSCounter.setUpdateFPSFrames(int, PrintStream)
public final long getFPSStartTime()
FPSCounter
FPSCounter.setUpdateFPSFrames(int, PrintStream)
.FPSCounter.resetFPSCounter()
.
getFPSStartTime
in interface FPSCounter
FPSCounter.setUpdateFPSFrames(int, PrintStream)
,
FPSCounter.resetFPSCounter()
public final long getLastFPSUpdateTime()
FPSCounter
FPSCounter.setUpdateFPSFrames(int, PrintStream)
.FPSCounter.resetFPSCounter()
.
getLastFPSUpdateTime
in interface FPSCounter
FPSCounter.setUpdateFPSFrames(int, PrintStream)
,
FPSCounter.resetFPSCounter()
public final long getLastFPSPeriod()
getLastFPSPeriod
in interface FPSCounter
FPSCounter.setUpdateFPSFrames(int, PrintStream)
,
FPSCounter.resetFPSCounter()
public final float getLastFPS()
getLastFPS
in interface FPSCounter
FPSCounter.getUpdateFPSFrames()
/ FPSCounter.getLastFPSPeriod()
FPSCounter.setUpdateFPSFrames(int, PrintStream)
,
FPSCounter.resetFPSCounter()
public final int getTotalFPSFrames()
getTotalFPSFrames
in interface FPSCounter
FPSCounter.getFPSStartTime()
up to FPSCounter.getLastFPSUpdateTime()
FPSCounter.setUpdateFPSFrames(int, PrintStream)
,
FPSCounter.resetFPSCounter()
public final long getTotalFPSDuration()
getTotalFPSDuration
in interface FPSCounter
FPSCounter.getLastFPSUpdateTime()
- FPSCounter.getFPSStartTime()
FPSCounter.setUpdateFPSFrames(int, PrintStream)
,
FPSCounter.resetFPSCounter()
public final float getTotalFPS()
getTotalFPS
in interface FPSCounter
FPSCounter.getTotalFPSFrames()
/ FPSCounter.getTotalFPSDuration()
FPSCounter.setUpdateFPSFrames(int, PrintStream)
,
FPSCounter.resetFPSCounter()
public final NativeSurface getNativeSurface()
getNativeSurface
in interface GLDrawable
public final long getHandle()
GLDrawable
NativeSurface.getSurfaceHandle()
,
ie the native surface handle of the underlying windowing toolkit.
getHandle
in interface GLDrawable
public final int getX()
getX
in interface NativeWindow
NativeWindow.getInsets()
public final int getY()
getY
in interface NativeWindow
NativeWindow.getInsets()
public final int getWidth()
GLDrawable
getWidth
in interface NativeSurface
getWidth
in interface GLDrawable
public final int getHeight()
GLDrawable
getHeight
in interface NativeSurface
getHeight
in interface GLDrawable
public final GLContext createContext(GLContext shareWith)
GLDrawable
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.
createContext
in interface GLDrawable
public final void setRealized(boolean realized)
GLDrawable
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:
GLCapabilities
, which are associated with
the attached NativeSurface
's AbstractGraphicsConfiguration
.NativeSurface's unlockSurface()
.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.
setRealized
in interface GLDrawable
public final boolean isRealized()
isRealized
in interface GLDrawable
public final GLCapabilitiesImmutable getChosenGLCapabilities()
GLDrawable
GLCapabilitiesImmutable
corresponding to the chosen
OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.NativeSurface
's
AbstractGraphicsConfiguration
, and if changes are necessary,
they should reflect those as well.
getChosenGLCapabilities
in interface GLDrawable
public final GLProfile getGLProfile()
GLDrawable
GLProfile
for this drawable.
Returns the GLProfile object, no copy.
getGLProfile
in interface GLDrawable
public boolean consumeEvent(NEWTEvent event)
NEWTEventConsumer
consumeEvent
in interface NEWTEventConsumer
public final void windowRepaint(int x, int y, int width, int height)
windowRepaint
in interface Window
public final void enqueueEvent(boolean wait, NEWTEvent event)
enqueueEvent
in interface Window
public final void runOnEDTIfAvail(boolean wait, Runnable task)
runOnEDTIfAvail
in interface Window
public final SurfaceUpdatedListener getSurfaceUpdatedListener(int index)
getSurfaceUpdatedListener
in interface Window
public final SurfaceUpdatedListener[] getSurfaceUpdatedListeners()
getSurfaceUpdatedListeners
in interface Window
public final void removeAllSurfaceUpdatedListener()
removeAllSurfaceUpdatedListener
in interface Window
public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
removeSurfaceUpdatedListener
in interface Window
public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l)
Window
com.jogamp.newt.event.SurfaceUpdatedListener
to the end of
the list.
addSurfaceUpdatedListener
in interface Window
public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException
Window
com.jogamp.newt.event.SurfaceUpdatedListener
at the
specified position in the list.
addSurfaceUpdatedListener
in interface Window
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
IndexOutOfBoundsException
- If the index is not within (0 <= index && index <= size()), or -1public void sendWindowEvent(int eventType)
sendWindowEvent
in interface Window
public final WindowListener getWindowListener(int index)
getWindowListener
in interface Window
public final WindowListener[] getWindowListeners()
getWindowListeners
in interface Window
public final void removeWindowListener(WindowListener l)
removeWindowListener
in interface Window
public final void addWindowListener(WindowListener l)
Window
WindowListener
to the end of
the list.
addWindowListener
in interface Window
public final void addWindowListener(int index, WindowListener l) throws IndexOutOfBoundsException
Window
WindowListener
at the
specified position in the list.
addWindowListener
in interface Window
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
IndexOutOfBoundsException
- If the index is not within (0 <= index && index <= size()), or -1public final void addKeyListener(KeyListener l)
Window
KeyListener
to the end of
the list.
addKeyListener
in interface Window
public final void addKeyListener(int index, KeyListener l)
Window
KeyListener
at the
specified position in the list.
addKeyListener
in interface Window
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 insertedpublic final void removeKeyListener(KeyListener l)
removeKeyListener
in interface Window
public final KeyListener getKeyListener(int index)
getKeyListener
in interface Window
public final KeyListener[] getKeyListeners()
getKeyListeners
in interface Window
public final void addMouseListener(MouseListener l)
Window
MouseListener
to the end of
the list.
addMouseListener
in interface Window
public final void addMouseListener(int index, MouseListener l)
Window
MouseListener
at the
specified position in the list.
addMouseListener
in interface Window
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 insertedpublic final void removeMouseListener(MouseListener l)
removeMouseListener
in interface Window
public final MouseListener getMouseListener(int index)
getMouseListener
in interface Window
public final MouseListener[] getMouseListeners()
getMouseListeners
in interface Window
public final int lockSurface()
NativeSurface
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).
lockSurface
in interface NativeSurface
NativeSurface.LOCK_SUCCESS
, NativeSurface.LOCK_SURFACE_CHANGED
or NativeSurface.LOCK_SURFACE_NOT_READY
.RecursiveLock
public final void unlockSurface() throws NativeWindowException
NativeSurface
NativeSurface.lockSurface()
The implementation shall also invoke AbstractGraphicsDevice.unlock()
for the final unlock (recursive count zero).
unlockSurface
in interface NativeSurface
NativeWindowException
NativeSurface.lockSurface()
,
RecursiveLock
public final boolean isSurfaceLockedByOtherThread()
NativeSurface
isSurfaceLockedByOtherThread
in interface NativeSurface
public final boolean isSurfaceLocked()
NativeSurface
isSurfaceLocked
in interface NativeSurface
public final Thread getSurfaceLockOwner()
NativeSurface
getSurfaceLockOwner
in interface NativeSurface
public final boolean surfaceSwap()
NativeSurface
surfaceSwap
in interface NativeSurface
public final long getWindowHandle()
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.
getWindowHandle
in interface NativeWindow
public final long getSurfaceHandle()
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.
getSurfaceHandle
in interface NativeSurface
public final AbstractGraphicsConfiguration getGraphicsConfiguration()
NativeSurface
getGraphicsConfiguration
in interface NativeSurface
javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
public final long getDisplayHandle()
NativeSurface
getDisplayHandle
in interface NativeSurface
public final int getScreenIndex()
NativeSurface
getScreenIndex
in interface NativeSurface
public final void surfaceUpdated(Object updater, NativeSurface ns, long when)
SurfaceUpdatedListener
surfaceUpdated
in interface SurfaceUpdatedListener
updater
- is the caller object who updated the surface,
e.g. a JOGL GLDrawable.ns
- the updated NativeSurfacewhen
- the time in ms, when the surface was updatedpublic static void main(String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |