|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jogamp.newt.Window
com.jogamp.newt.opengl.GLWindow
public class GLWindow
An implementation of Window
which is customized for OpenGL
use, and which implements the GLAutoDrawable
interface.
This implementation does not make the OpenGL context current
before calling the various input EventListener callbacks (MouseListener, KeyListener,
etc.).
This design decision is made to favor a more performant and simplified
implementation, as well as the event dispatcher shall be allowed
not having a notion about OpenGL.
Field Summary |
---|
Fields inherited from class com.jogamp.newt.Window |
---|
caps, ClickTimeout, config, DEBUG_IMPLEMENTATION, DEBUG_KEY_EVENT, DEBUG_MOUSE_EVENT, DEBUG_WINDOW_EVENT, fullscreen, height, nfs_height, nfs_width, nfs_x, nfs_y, parentNativeWindow, parentWindowHandle, screen, title, undecorated, visible, width, windowHandle, windowLock, x, y |
Fields inherited from interface javax.media.opengl.GLAutoDrawable |
---|
SCREEN_CHANGE_ACTION_ENABLED |
Fields inherited from interface javax.media.nativewindow.NativeWindow |
---|
LOCK_SUCCESS, LOCK_SURFACE_CHANGED, LOCK_SURFACE_NOT_READY, LOCK_SURFACE_UNLOCKED |
Constructor Summary | |
---|---|
protected |
GLWindow(Window window)
Constructor. |
Method Summary | |
---|---|
void |
addGLEventListener(GLEventListener listener)
Adds a GLEventListener to this drawable. |
void |
addGLEventListener(int index,
GLEventListener listener)
|
void |
addKeyListener(int index,
KeyListener l)
Inserts the given KeyListener at the
specified position in the list. |
void |
addMouseListener(int index,
MouseListener l)
Inserts the given MouseListener at the
specified position in the list. |
void |
addSurfaceUpdatedListener(int index,
SurfaceUpdatedListener l)
Inserts the given com.jogamp.newt.event.SurfaceUpdatedListener at the
specified position in the list. |
void |
addWindowListener(int index,
WindowListener l)
Inserts the given WindowListener at the
specified position in the list. |
protected void |
closeNative()
|
static GLWindow |
create(GLCapabilities caps)
Creates a new GLWindow attaching a new decorated Window on the local display, screen 0, with a dummy visual ID and given GLCapabilities - owning the window |
static GLWindow |
create(GLCapabilities caps,
boolean undecorated)
Creates a new GLWindow attaching a new Window on the local display, screen 0, with a dummy visual ID and given GLCapabilities - owning the window |
static GLWindow |
create(NativeWindow parentNativeWindow,
GLCapabilities caps)
Creates a new GLWindow attaching a new native child Window of the given parentNativeWindow
with the given GLCapabilities - owning the Window |
static GLWindow |
create(Window window)
Creates a new GLWindow attaching the given window - not owning the 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. |
protected void |
createNativeImpl()
Create native windowHandle, ie creates a new native invisible window. |
void |
destroy(boolean deep)
|
void |
display()
Causes OpenGL rendering to be performed for this GLAutoDrawable by calling display(..) for all
registered GLEventListener s. |
void |
display(boolean forceReshape)
|
void |
enablePerfLog(boolean v)
|
boolean |
getAutoSwapBufferMode()
This implementation uses a static value |
GLCapabilities |
getChosenGLCapabilities()
Fetches the GLCapabilities 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. |
long |
getCurrentTime()
|
long |
getDuration()
|
GLDrawableFactory |
getFactory()
|
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 NativeWindow.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 height of the client area of this window |
Window |
getInnerWindow()
Returns the most inner Window instance. Currently only GLWindow
has an aggregation to an inner Window instance. |
Insets |
getInsets()
Returns the insets for this native window (the difference between the size of the toplevel window with the decorations and the client area). |
KeyListener |
getKeyListener(int index)
|
KeyListener[] |
getKeyListeners()
|
Exception |
getLockedStack()
Return the lock-exception, or null if not locked. |
MouseListener |
getMouseListener(int index)
|
MouseListener[] |
getMouseListeners()
|
NativeWindow |
getNativeWindow()
|
NativeWindow |
getParentNativeWindow()
|
boolean |
getPerfLogEnabled()
|
Capabilities |
getRequestedCapabilities()
|
Screen |
getScreen()
|
long |
getStartTime()
|
long |
getSurfaceHandle()
Returns the handle to the surface for this NativeWindow. |
SurfaceUpdatedListener |
getSurfaceUpdatedListener(int index)
|
SurfaceUpdatedListener[] |
getSurfaceUpdatedListeners()
|
String |
getTitle()
|
int |
getTotalFrames()
|
int |
getWidth()
Returns the width of the client area of this window |
long |
getWindowHandle()
Returns the window handle for this NativeWindow. |
WindowListener |
getWindowListener(int index)
|
WindowListener[] |
getWindowListeners()
|
Object |
getWrappedWindow()
If this Window actually wraps one from another toolkit such as the AWT, this will return a non-null value. |
int |
getX()
|
int |
getY()
|
boolean |
isDestroyed()
|
boolean |
isFullscreen()
|
boolean |
isNativeWindowValid()
|
boolean |
isRealized()
|
boolean |
isSurfaceLocked()
Return if surface is locked |
boolean |
isUndecorated()
|
boolean |
isVisible()
|
int |
lockSurface()
Recursive and blocking lockSurface() implementation |
void |
removeAllSurfaceUpdatedListener()
|
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)
|
void |
reparentWindow(NativeWindow newParent,
Screen newScreen)
Change this window's parent window. |
void |
requestFocus()
|
void |
sendEvent(NEWTEvent e)
|
void |
setAutoSwapBufferMode(boolean onOrOff)
This implementation uses a static value |
void |
setContext(GLContext newCtx)
Associate a new context to this drawable. |
boolean |
setFullscreen(boolean fullscreen)
|
protected boolean |
setFullscreenImpl(boolean fullscreen,
int x,
int y,
int w,
int h)
|
GL |
setGL(GL gl)
Sets the GL pipeline object this GLAutoDrawable uses. |
void |
setPosition(int x,
int y)
Sets the location of the top left corner of the window, including decorations (so the client area will be placed at x+insets.left,y+insets.top .This call is ignored if in fullscreen mode. |
protected void |
setPositionImpl(int x,
int y)
|
void |
setRealized(boolean realized)
Indicates to on-screen GLDrawable implementations whether the underlying window has been created and can be drawn into. |
void |
setRunPumpMessages(boolean onoff)
Deprecated. EXPERIMENTAL, semantic is about to be removed after further verification. |
void |
setSize(int width,
int height)
Sets the size of the client area of the window, excluding decorations Total size of the window will be width+insets.left+insets.right, height+insets.top+insets.bottom |
protected void |
setSizeImpl(int width,
int height)
|
void |
setTitle(String title)
|
void |
setUndecorated(boolean value)
|
void |
setVisible(boolean visible)
setVisible makes the window and children visible if visible is true,
otherwise the window and children becomes invisible. |
protected void |
setVisibleImpl(boolean visible)
|
boolean |
surfaceSwap()
Provide a mechanism to utilize custom (pre-) swap surface code. |
void |
surfaceUpdated(Object updater,
NativeWindow window0,
long when)
Notification of a surface update event. |
void |
swapBuffers()
Swaps the front and back buffers of this drawable. |
String |
toString()
|
void |
unlockSurface()
Recursive and unblocking unlockSurface() implementation |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface javax.media.opengl.GLAutoDrawable |
---|
destroy |
Constructor Detail |
---|
protected GLWindow(Window window)
#create()
instead.
Method Detail |
---|
public static GLWindow create(Window window)
public static GLWindow create(NativeWindow parentNativeWindow, GLCapabilities caps)
parentNativeWindow
with the given GLCapabilities - owning the Window
public static GLWindow create(GLCapabilities caps)
public static GLWindow create(GLCapabilities caps, boolean undecorated)
public boolean isNativeWindowValid()
isNativeWindowValid
in class Window
public boolean isDestroyed()
isDestroyed
in class Window
public final Window getInnerWindow()
Window
GLWindow
has an aggregation to an inner Window instance.
getInnerWindow
in class Window
public final Object getWrappedWindow()
Window
getWrappedWindow
in class Window
public void setRunPumpMessages(boolean onoff)
Display.pumpMessages()
in the display()
call.Display.pumpMessages()
.
The idea was that in a single threaded environment with one Display
and many Window
's,
a performance benefit was expected while disabling the implicit Display.pumpMessages()
and
do it once via GLWindow#runCurrentThreadPumpMessage()
This could not have been verified. No measurable difference could have been recognized.
Best performance has been achieved with one GLWindow per thread.
Enabling local pump messages while using the EDT,
NewtFactory.setUseEDT(boolean)
,
will result in an exception.
protected void createNativeImpl()
Window
createNativeImpl
in class Window
protected void closeNative()
closeNative
in class Window
public void destroy(boolean deep)
destroy
in class Window
deep
- If true, all resources, ie listeners, parent handles, size, position
and the referenced NEWT screen and display, will be destroyed as well. Be aware that if you call
this method with deep = true, you will not be able to regenerate the Window.Window.destroy()
public boolean getPerfLogEnabled()
public void enablePerfLog(boolean v)
protected void setVisibleImpl(boolean visible)
setVisibleImpl
in class Window
public void reparentWindow(NativeWindow newParent, Screen newScreen)
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 class Window
newParent
- the new parent NativeWindow. If null, this Window becomes a top level window.newScreen
- if not null and this window handle is not yet set
this Screen is being used.public 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( 0In case this window is a child window and a parent
NativeWindow
is being used,
the parent'sNativeWindow
handle is retrieved viaNativeWindow.getWindowHandle()
.
If this action fails, ie if the parentNativeWindow
is not valid yet,
no native window is created yet andsetVisible(true)
shall be repeated when it is.
- Overrides:
setVisible
in classWindow
public Capabilities getRequestedCapabilities()
getRequestedCapabilities
in class Window
public NativeWindow getParentNativeWindow()
getParentNativeWindow
in class Window
public Screen getScreen()
getScreen
in class Window
public void setTitle(String title)
setTitle
in class Window
public String getTitle()
getTitle
in class Window
public void setUndecorated(boolean value)
setUndecorated
in class Window
public boolean isUndecorated()
isUndecorated
in class Window
public void requestFocus()
requestFocus
in class Window
public Insets getInsets()
Window
getInsets
in class Window
public void setSize(int width, int height)
Window
width+insets.left+insets.right, height+insets.top+insets.bottom
Zero size semantics are respected, see Window.setVisible(boolean)
:
if ( 0 != windowHandle && 0>=width*height && visible ) { setVisible(false); } else if ( 0 == windowHandle && 0This call is ignored if in fullscreen mode.
- Overrides:
setSize
in classWindow
- Parameters:
width
- of the client area of the windowheight
- of the client area of the window
protected void setSizeImpl(int width, int height)
setSizeImpl
in class Window
public void setPosition(int x, int y)
Window
x+insets.left,y+insets.top
.
setPosition
in class Window
x
- coord of the top left cornery
- coord of the top left cornerprotected void setPositionImpl(int x, int y)
setPositionImpl
in class Window
public boolean setFullscreen(boolean fullscreen)
setFullscreen
in class Window
protected boolean setFullscreenImpl(boolean fullscreen, int x, int y, int w, int h)
setFullscreenImpl
in class Window
public boolean isVisible()
isVisible
in class Window
public int getX()
getX
in class Window
public int getY()
getY
in class Window
public int getWidth()
Window
getWidth
in interface NativeWindow
getWidth
in interface GLDrawable
getWidth
in class Window
public int getHeight()
Window
getHeight
in interface NativeWindow
getHeight
in interface GLDrawable
getHeight
in class Window
public boolean isFullscreen()
isFullscreen
in class Window
public void sendEvent(NEWTEvent e)
sendEvent
in class Window
public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l)
Window
com.jogamp.newt.event.SurfaceUpdatedListener
at the
specified position in the list.
addSurfaceUpdatedListener
in class 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 void removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
removeSurfaceUpdatedListener
in class Window
public void removeAllSurfaceUpdatedListener()
removeAllSurfaceUpdatedListener
in class Window
public SurfaceUpdatedListener getSurfaceUpdatedListener(int index)
getSurfaceUpdatedListener
in class Window
public SurfaceUpdatedListener[] getSurfaceUpdatedListeners()
getSurfaceUpdatedListeners
in class Window
public void surfaceUpdated(Object updater, NativeWindow window0, long when)
SurfaceUpdatedListener
surfaceUpdated
in interface SurfaceUpdatedListener
surfaceUpdated
in class Window
updater
- is the caller object who updated the surface,
e.g. a JOGL GLDrawable.window0
- the NativeWindow, which surface is updatedwhen
- the time in ms, when the surface was updatedpublic void addMouseListener(int index, MouseListener l)
Window
MouseListener
at the
specified position in the list.
addMouseListener
in class 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 void removeMouseListener(MouseListener l)
removeMouseListener
in class Window
public MouseListener getMouseListener(int index)
getMouseListener
in class Window
public MouseListener[] getMouseListeners()
getMouseListeners
in class Window
public void addKeyListener(int index, KeyListener l)
Window
KeyListener
at the
specified position in the list.
addKeyListener
in class 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 void removeKeyListener(KeyListener l)
removeKeyListener
in class Window
public KeyListener getKeyListener(int index)
getKeyListener
in class Window
public KeyListener[] getKeyListeners()
getKeyListeners
in class Window
public void addWindowListener(int index, WindowListener l)
Window
WindowListener
at the
specified position in the list.
addWindowListener
in class 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 void removeWindowListener(WindowListener l)
removeWindowListener
in class Window
public WindowListener getWindowListener(int index)
getWindowListener
in class Window
public WindowListener[] getWindowListeners()
getWindowListeners
in class Window
public String toString()
toString
in interface GLDrawable
toString
in class Window
public GLDrawableFactory getFactory()
getFactory
in interface GLDrawable
public 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 this drawable. If multiple
listeners are added to a given drawable, they are notified of
events in an arbitrary order.
addGLEventListener
in interface GLAutoDrawable
public void addGLEventListener(int index, GLEventListener listener)
public 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 display()
GLAutoDrawable
display(..)
for all
registered GLEventListener
s. Called automatically by the
window system toolkit upon receiving a repaint() request. this
routine may 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
public void display(boolean forceReshape)
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 long getStartTime()
public long getCurrentTime()
public long getDuration()
public int getTotalFrames()
public int lockSurface() throws NativeWindowException
Window
lockSurface
in interface NativeWindow
lockSurface
in class Window
NativeWindow.LOCK_SUCCESS
, NativeWindow.LOCK_SURFACE_CHANGED
or NativeWindow.LOCK_SURFACE_NOT_READY
.
NativeWindowException
- if surface is already lockedToolkitLock
public void unlockSurface()
Window
unlockSurface
in interface NativeWindow
unlockSurface
in class Window
NativeWindow.lockSurface()
,
ToolkitLock
public boolean isSurfaceLocked()
NativeWindow
isSurfaceLocked
in interface NativeWindow
isSurfaceLocked
in class Window
public Exception getLockedStack()
NativeWindow
NativeWindow.lockSurface()
and hence holds the locker's call stack.
getLockedStack
in interface NativeWindow
getLockedStack
in class Window
public boolean surfaceSwap()
NativeWindow
surfaceSwap
in interface NativeWindow
surfaceSwap
in class Window
public 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
getWindowHandle
in class Window
public long getSurfaceHandle()
NativeWindow
The surface handle should be set/update by NativeWindow.lockSurface()
,
where NativeWindow.unlockSurface()
is not allowed to modify it.
After NativeWindow.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 NativeWindow
getSurfaceHandle
in class Window
public AbstractGraphicsConfiguration getGraphicsConfiguration()
NativeWindow
getGraphicsConfiguration
in interface NativeWindow
getGraphicsConfiguration
in class Window
GraphicsConfigurationFactory.chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
public NativeWindow getNativeWindow()
getNativeWindow
in interface GLDrawable
public long getHandle()
GLDrawable
NativeWindow.getSurfaceHandle()
,
ie the native surface handle of the underlying windowing toolkit.
getHandle
in interface GLDrawable
public 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 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
NativeWindow's lockSurface()
and if successfull:
GLCapabilities
, which are associated with
the attached NativeWindow
's AbstractGraphicsConfiguration
.NativeWindow's unlockSurface()
.NativeWindow'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 boolean isRealized()
isRealized
in interface GLDrawable
public GLCapabilities getChosenGLCapabilities()
GLDrawable
GLCapabilities
corresponding to the chosen
OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.NativeWindow
's
AbstractGraphicsConfiguration
, and if changes are necessary,
they should reflect those as well.
getChosenGLCapabilities
in interface GLDrawable
public GLProfile getGLProfile()
GLDrawable
GLProfile
for this drawable.
Returns the GLProfile object, no copy.
getGLProfile
in interface GLDrawable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |