com.jogamp.newt.opengl
Class GLWindow

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

public class GLWindow
extends Window
implements GLAutoDrawable

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 GLEventListeners.
 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 com.jogamp.newt.Window
addChild, addKeyListener, addMouseListener, addPaintListener, addPaintListener, addSurfaceUpdatedListener, addWindowListener, create, create, destroy, enqueueKeyEvent, enqueueMouseEvent, enqueueWindowEvent, getDisplayHandle, getPaintListener, getScreenIndex, getSurfaceLockOwner, getThreadName, getWindowLock, hasDeviceChanged, invalidate, invalidate, isUndecorated, removeChild, removePaintListener, reparentWindowImpl, requestFocusImpl, runOnEDTIfAvail, sendKeyEvent, sendMouseEvent, sendPaintEvent, sendPaintEvent, sendWindowEvent, setHandleDestroyNotify, setTitleImpl, shouldNotCallThis, toHexString, toHexString, windowDestroyed, windowDestroyNotify, windowIsLocked, windowLock, windowUnlock
 
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

GLWindow

protected GLWindow(Window window)
Constructor. Do not call this directly -- use #create() instead.

Method Detail

create

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


create

public 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


create

public 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


create

public 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


isNativeWindowValid

public boolean isNativeWindowValid()
Overrides:
isNativeWindowValid in class Window
Returns:
true if the native window handle is valid and ready to operate

isDestroyed

public boolean isDestroyed()
Overrides:
isDestroyed in class Window

getInnerWindow

public final Window getInnerWindow()
Description copied from class: Window
Returns the most inner Window instance.
Currently only GLWindow has an aggregation to an inner Window instance.

Overrides:
getInnerWindow in class Window

getWrappedWindow

public final Object getWrappedWindow()
Description copied from class: Window
If this Window actually wraps one from another toolkit such as the AWT, this will return a non-null value.

Overrides:
getWrappedWindow in class Window

setRunPumpMessages

public void setRunPumpMessages(boolean onoff)
Deprecated. EXPERIMENTAL, semantic is about to be removed after further verification.

EXPERIMENTAL
Enable or disables running the Display.pumpMessages() in the display() call.
The default behavior is to run 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.


createNativeImpl

protected void createNativeImpl()
Description copied from class: Window
Create native windowHandle, ie creates a new native invisible window.

Specified by:
createNativeImpl in class Window

closeNative

protected void closeNative()
Specified by:
closeNative in class Window

destroy

public void destroy(boolean deep)
Overrides:
destroy in class Window
Parameters:
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.
See Also:
Window.destroy()

getPerfLogEnabled

public boolean getPerfLogEnabled()

enablePerfLog

public void enablePerfLog(boolean v)

setVisibleImpl

protected void setVisibleImpl(boolean visible)
Specified by:
setVisibleImpl in class Window

reparentWindow

public void reparentWindow(NativeWindow newParent,
                           Screen newScreen)
Description copied from class: 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.

Overrides:
reparentWindow in class Window
Parameters:
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.

setVisible

public void setVisible(boolean visible)
Description copied from class: 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

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.

Overrides:
setVisible in class Window

getRequestedCapabilities

public Capabilities getRequestedCapabilities()
Overrides:
getRequestedCapabilities in class Window

getParentNativeWindow

public NativeWindow getParentNativeWindow()
Overrides:
getParentNativeWindow in class Window

getScreen

public Screen getScreen()
Overrides:
getScreen in class Window

setTitle

public void setTitle(String title)
Overrides:
setTitle in class Window

getTitle

public String getTitle()
Overrides:
getTitle in class Window

setUndecorated

public void setUndecorated(boolean value)
Overrides:
setUndecorated in class Window

isUndecorated

public boolean isUndecorated()
Overrides:
isUndecorated in class Window

requestFocus

public void requestFocus()
Overrides:
requestFocus in class Window

getInsets

public Insets getInsets()
Description copied from class: Window
Returns the insets for this native window (the difference between the size of the toplevel window with the decorations and the client area).

Overrides:
getInsets in class Window
Returns:
insets for this platform window

setSize

public void setSize(int width,
                    int height)
Description copied from class: Window
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

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

 if ( 0 != windowHandle && 0>=width*height && visible ) {
      setVisible(false);
 } else if ( 0 == windowHandle && 0

This call is ignored if in fullscreen mode.

Overrides:
setSize in class Window
Parameters:
width - of the client area of the window
height - of the client area of the window

setSizeImpl

protected void setSizeImpl(int width,
                           int height)
Specified by:
setSizeImpl in class Window

setPosition

public void setPosition(int x,
                        int y)
Description copied from class: Window
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.

Overrides:
setPosition in class Window
Parameters:
x - coord of the top left corner
y - coord of the top left corner

setPositionImpl

protected void setPositionImpl(int x,
                               int y)
Specified by:
setPositionImpl in class Window

setFullscreen

public boolean setFullscreen(boolean fullscreen)
Overrides:
setFullscreen in class Window

setFullscreenImpl

protected boolean setFullscreenImpl(boolean fullscreen,
                                    int x,
                                    int y,
                                    int w,
                                    int h)
Specified by:
setFullscreenImpl in class Window

isVisible

public boolean isVisible()
Overrides:
isVisible in class Window

getX

public int getX()
Overrides:
getX in class Window

getY

public int getY()
Overrides:
getY in class Window

getWidth

public int getWidth()
Description copied from class: Window
Returns the width of the client area of this window

Specified by:
getWidth in interface NativeWindow
Specified by:
getWidth in interface GLDrawable
Overrides:
getWidth in class Window
Returns:
width of the client area

getHeight

public int getHeight()
Description copied from class: Window
Returns the height of the client area of this window

Specified by:
getHeight in interface NativeWindow
Specified by:
getHeight in interface GLDrawable
Overrides:
getHeight in class Window
Returns:
height of the client area

isFullscreen

public boolean isFullscreen()
Overrides:
isFullscreen in class Window

sendEvent

public void sendEvent(NEWTEvent e)
Overrides:
sendEvent in class Window

addSurfaceUpdatedListener

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

Overrides:
addSurfaceUpdatedListener in class 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

removeSurfaceUpdatedListener

public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
Overrides:
removeSurfaceUpdatedListener in class Window

removeAllSurfaceUpdatedListener

public void removeAllSurfaceUpdatedListener()
Overrides:
removeAllSurfaceUpdatedListener in class Window

getSurfaceUpdatedListener

public SurfaceUpdatedListener getSurfaceUpdatedListener(int index)
Overrides:
getSurfaceUpdatedListener in class Window

getSurfaceUpdatedListeners

public SurfaceUpdatedListener[] getSurfaceUpdatedListeners()
Overrides:
getSurfaceUpdatedListeners in class Window

surfaceUpdated

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

Specified by:
surfaceUpdated in interface SurfaceUpdatedListener
Overrides:
surfaceUpdated in class Window
Parameters:
updater - is the caller object who updated the surface, e.g. a JOGL GLDrawable.
window0 - the NativeWindow, which surface is updated
when - the time in ms, when the surface was updated

addMouseListener

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

Overrides:
addMouseListener in class 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 void removeMouseListener(MouseListener l)
Overrides:
removeMouseListener in class Window

getMouseListener

public MouseListener getMouseListener(int index)
Overrides:
getMouseListener in class Window

getMouseListeners

public MouseListener[] getMouseListeners()
Overrides:
getMouseListeners in class Window

addKeyListener

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

Overrides:
addKeyListener in class 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 void removeKeyListener(KeyListener l)
Overrides:
removeKeyListener in class Window

getKeyListener

public KeyListener getKeyListener(int index)
Overrides:
getKeyListener in class Window

getKeyListeners

public KeyListener[] getKeyListeners()
Overrides:
getKeyListeners in class Window

addWindowListener

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

Overrides:
addWindowListener in class 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

removeWindowListener

public void removeWindowListener(WindowListener l)
Overrides:
removeWindowListener in class Window

getWindowListener

public WindowListener getWindowListener(int index)
Overrides:
getWindowListener in class Window

getWindowListeners

public WindowListener[] getWindowListeners()
Overrides:
getWindowListeners in class Window

toString

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

getFactory

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

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 this drawable. If multiple listeners are added to a given drawable, they are notified of events in an arbitrary order.

Specified by:
addGLEventListener in interface GLAutoDrawable

addGLEventListener

public void addGLEventListener(int index,
                               GLEventListener listener)

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

display

public void display()
Description copied from interface: GLAutoDrawable
Causes OpenGL rendering to be performed for this GLAutoDrawable by calling display(..) for all registered GLEventListeners. 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 GLEventListeners before making the actual display(..) calls, in case this has not been done yet.

Specified by:
display in interface GLAutoDrawable

display

public void display(boolean forceReshape)

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

getStartTime

public long getStartTime()

getCurrentTime

public long getCurrentTime()

getDuration

public long getDuration()

getTotalFrames

public int getTotalFrames()

lockSurface

public int lockSurface()
                throws NativeWindowException
Description copied from class: Window
Recursive and blocking lockSurface() implementation

Specified by:
lockSurface in interface NativeWindow
Overrides:
lockSurface in class Window
Returns:
NativeWindow.LOCK_SUCCESS, NativeWindow.LOCK_SURFACE_CHANGED or NativeWindow.LOCK_SURFACE_NOT_READY.
Throws:
NativeWindowException - if surface is already locked
See Also:
ToolkitLock

unlockSurface

public void unlockSurface()
Description copied from class: Window
Recursive and unblocking unlockSurface() implementation

Specified by:
unlockSurface in interface NativeWindow
Overrides:
unlockSurface in class Window
See Also:
NativeWindow.lockSurface(), ToolkitLock

isSurfaceLocked

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

Specified by:
isSurfaceLocked in interface NativeWindow
Overrides:
isSurfaceLocked in class Window

getLockedStack

public Exception getLockedStack()
Description copied from interface: NativeWindow
Return the lock-exception, or null if not locked. The lock-exception is created at NativeWindow.lockSurface() and hence holds the locker's call stack.

Specified by:
getLockedStack in interface NativeWindow
Overrides:
getLockedStack in class Window

surfaceSwap

public boolean surfaceSwap()
Description copied from interface: NativeWindow
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 NativeWindow
Overrides:
surfaceSwap in class Window
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 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
Overrides:
getWindowHandle in class Window

getSurfaceHandle

public long getSurfaceHandle()
Description copied from interface: NativeWindow
Returns the handle to the surface for this 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.

Specified by:
getSurfaceHandle in interface NativeWindow
Overrides:
getSurfaceHandle in class Window

getGraphicsConfiguration

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

Specified by:
getGraphicsConfiguration in interface NativeWindow
Overrides:
getGraphicsConfiguration in class Window
See Also:
GraphicsConfigurationFactory.chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)

getNativeWindow

public NativeWindow getNativeWindow()
Specified by:
getNativeWindow in interface GLDrawable

getHandle

public long getHandle()
Description copied from interface: GLDrawable
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.

Specified by:
getHandle in interface GLDrawable

createContext

public 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 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 NativeWindow's lockSurface() and if successfull:


This is important since 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.

Specified by:
setRealized in interface GLDrawable

isRealized

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

getChosenGLCapabilities

public GLCapabilities getChosenGLCapabilities()
Description copied from interface: GLDrawable
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.
This object shall be directly associated to the attached NativeWindow'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 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


Copyright 2010 JogAmp Community.