|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.javafx.newt.Window com.sun.javafx.newt.opengl.GLWindow
public class GLWindow
An implementation of Window
which is customized for OpenGL
use, and which implements the GLAutoDrawable
interface. For convenience, this
window class guarantees that its OpenGL context is current inside
the various EventListeners' callbacks (MouseListener, KeyListener,
etc.).
Best performance is currently achieved with default settings,
setEventHandlerMode(int)
to EVENT_HANDLER_GL_NONE
and one thread per GLWindow. To ensure compatibility with the
underlying platform, window shall also be created within your
working thread. See comment at setRunPumpMessages(boolean)
.
Field Summary | |
---|---|
static int |
EVENT_HANDLER_GL_CURRENT
Event handling mode: EVENT_HANDLER_GL_CURRENT. |
static int |
EVENT_HANDLER_GL_NONE
Event handling mode: EVENT_HANDLER_GL_NONE. |
Fields inherited from class com.sun.javafx.newt.Window |
---|
ClickTimeout, config, DEBUG_IMPLEMENTATION, DEBUG_KEY_EVENT, DEBUG_MOUSE_EVENT, DEBUG_WINDOW_EVENT, eventMask, fullscreen, height, lockedStack, screen, title, undecorated, visible, width, windowHandle, 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 |
Constructor Summary | |
---|---|
protected |
GLWindow(Window window,
boolean ownerOfDisplayAndScreen)
Constructor. |
Method Summary | |
---|---|
void |
addGLEventListener(GLEventListener listener)
Adds a GLEventListener to this drawable. |
void |
addKeyListener(KeyListener l)
|
void |
addMouseListener(MouseListener l)
|
void |
addWindowListener(WindowListener l)
|
protected void |
closeNative()
|
static GLWindow |
create()
Creates a new GLWindow on the local display, screen 0, with a dummy visual ID, and with the default GLCapabilities. |
static GLWindow |
create(boolean undecorated)
|
static GLWindow |
create(GLCapabilities caps)
|
static GLWindow |
create(GLCapabilities caps,
boolean undecorated)
Creates a new GLWindow on the local display, screen 0, with a dummy visual ID, and with the given GLCapabilities. |
static GLWindow |
create(Window window)
Creates a new GLWindow referring to 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. |
protected void |
createNative(long parentWindowHandle,
Capabilities caps)
Create native windowHandle, ie creates a new native invisible window. |
void |
destroy()
destroys the window and releases windowing related resources. |
void |
display()
Causes OpenGL rendering to be performed for this GLAutoDrawable by calling display(..) for all
registered GLEventListener s. |
protected void |
dispose(boolean regenerate)
|
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()
|
int |
getEventHandlerMode()
|
GLDrawableFactory |
getFactory()
|
GL |
getGL()
Returns the GL pipeline object this GLAutoDrawable uses. |
GLProfile |
getGLProfile()
Fetches the GLProfile for this drawable. |
int |
getHeight()
Returns the height of the client area of this window |
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[] |
getKeyListeners()
|
Exception |
getLockedStack()
Return the lock-exception, or null if not locked. |
MouseListener[] |
getMouseListeners()
|
NativeWindow |
getNativeWindow()
|
boolean |
getPerfLogEnabled()
|
Screen |
getScreen()
|
long |
getStartTime()
|
long |
getSurfaceHandle()
Returns the handle to the surface for this NativeWindow. |
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[] |
getWindowListeners()
|
int |
getX()
|
int |
getY()
|
boolean |
isFullscreen()
|
boolean |
isSurfaceLocked()
Return if surface is locked |
boolean |
isUndecorated()
|
boolean |
isVisible()
|
int |
lockSurface()
Lock the surface of this native window |
void |
removeGLEventListener(GLEventListener listener)
Removes a GLEventListener from this drawable. |
void |
removeKeyListener(KeyListener l)
|
void |
removeMouseListener(MouseListener l)
|
void |
removeWindowListener(WindowListener l)
|
static void |
runCurrentThreadPumpMessage()
Deprecated. EXPERIMENTAL, semantic is about to be removed after further verification. |
void |
setAutoSwapBufferMode(boolean onOrOff)
This implementation uses a static value |
void |
setContext(GLContext newCtx)
Associate a new context to this drawable. |
void |
setEventHandlerMode(int mode)
Sets the event handling mode. |
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 top left corner of the window, including decorations (so the client area will be placed at x+insets.left,y+insets.top . |
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 |
void |
setTitle(String title)
|
void |
setUndecorated(boolean value)
|
void |
setVisible(boolean visible)
|
boolean |
surfaceSwap()
Provide a mechanism to utilize custom (pre-) swap surface code. |
void |
surfaceUpdated()
Method invoked after the render toolkit (e.g. |
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 window handle, see NativeWindow.getWindowHandle() ,
or the surface handle, see NativeWindow.lockSurface() |
Methods inherited from class com.sun.javafx.newt.Window |
---|
addPaintListener, clearEventMask, create, create, disposeSurfaceHandle, getDisplayHandle, getGraphicsConfiguration, getScreenIndex, getWrappedWindow, hasDeviceChanged, invalidate, removePaintListener, requestFocus, sendKeyEvent, sendMouseEvent, sendPaintEvent, sendWindowEvent, setAutoDrawableClient, windowDestroyed, windowDestroyNotify, wrapHandle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int EVENT_HANDLER_GL_NONE
com.sun.javafx.newt.GLWindow#setEventHandlerMode(int)
,
Constant Field Valuespublic static final int EVENT_HANDLER_GL_CURRENT
com.sun.javafx.newt.GLWindow#setEventHandlerMode(int)
,
Constant Field ValuesConstructor Detail |
---|
protected GLWindow(Window window, boolean ownerOfDisplayAndScreen)
create()
instead.
Method Detail |
---|
public static GLWindow create()
public static GLWindow create(boolean undecorated)
public static GLWindow create(Window window)
public static GLWindow create(GLCapabilities caps)
public static GLWindow create(GLCapabilities caps, boolean undecorated)
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 runCurrentThreadPumpMessage()
This could not have been verified. No measurable difference could have been recognized.
Best performance has been achieved with one GLWindow per thread.
protected void createNative(long parentWindowHandle, Capabilities caps)
Window
createNative
in class Window
protected void closeNative()
closeNative
in class Window
protected void dispose(boolean regenerate)
public void destroy()
NativeWindow
destroy
in interface NativeWindow
destroy
in interface GLAutoDrawable
destroy
in class Window
public boolean getPerfLogEnabled()
public void enablePerfLog(boolean v)
public void setEventHandlerMode(int mode)
com.sun.javafx.newt.GLWindow#EVENT_HANDLER_GL_NONE
,
com.sun.javafx.newt.GLWindow#EVENT_HANDLER_GL_CURRENT
public int getEventHandlerMode()
public void setVisible(boolean visible)
setVisible
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 setSize(int width, int height)
Window
width+insets.left+insets.right, height+insets.top+insets.bottom
setSize
in class Window
width
- of the client area of the windowheight
- of the client area of the windowpublic 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 cornerpublic Insets getInsets()
Window
getInsets
in class Window
public boolean setFullscreen(boolean fullscreen)
setFullscreen
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 addMouseListener(MouseListener l)
addMouseListener
in class Window
public void removeMouseListener(MouseListener l)
removeMouseListener
in class Window
public MouseListener[] getMouseListeners()
getMouseListeners
in class Window
public void addKeyListener(KeyListener l)
addKeyListener
in class Window
public void removeKeyListener(KeyListener l)
removeKeyListener
in class Window
public KeyListener[] getKeyListeners()
getKeyListeners
in class Window
public void addWindowListener(WindowListener l)
addWindowListener
in class Window
public void removeWindowListener(WindowListener l)
removeWindowListener
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 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 static void runCurrentThreadPumpMessage()
setRunPumpMessages(boolean)
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 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 NativeWindow getNativeWindow()
getNativeWindow
in interface GLDrawable
public int lockSurface() throws NativeWindowException
NativeWindow
The window handle, see NativeWindow.getWindowHandle()
,
and the surface handle, see NativeWindow.lockSurface()
,
shall be set and be valid after a successfull call,
ie a return value other than NativeWindow.LOCK_SURFACE_NOT_READY
.
The semantics of the underlying native locked resource
may be related to the ToolkitLock
one. Hence it is
important that implementation of both harmonize well.
The implementation may want to aquire the ToolkitLock
first to become it's owner before proceeding with it's
actual surface lock.
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()
NativeWindow
NativeWindow.getWindowHandle()
,
or the surface handle, see NativeWindow.lockSurface()
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 void surfaceUpdated()
NativeWindow
surfaceUpdated
in interface NativeWindow
surfaceUpdated
in class Window
public long getWindowHandle()
NativeWindow
The window 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 window handle is still valid.
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 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 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 |