org.xith3d.render.jsr231
Class CanvasPeerImplSwing

java.lang.Object
  extended by org.xith3d.render.CanvasPeer
      extended by org.xith3d.render.jsr231.CanvasPeerImplBase
          extended by org.xith3d.render.jsr231.CanvasPeerImplSwing
All Implemented Interfaces:
java.util.EventListener, javax.media.opengl.GLEventListener, org.jagatoo.input.render.InputSourceWindow

public class CanvasPeerImplSwing
extends CanvasPeerImplBase
implements javax.media.opengl.GLEventListener

The CanvasPeer implementation for the official Java OpenGL Bindings (JOGL) and Swing. Its essentially CanvasPeerAWTImpl except it creates a GLJPanel rather than a GLCanvas.


Field Summary
 
Fields inherited from class org.xith3d.render.jsr231.CanvasPeerImplBase
swapIntervalChanged
 
Fields inherited from class org.xith3d.render.CanvasPeer
isGammaChanged, oglInfo
 
Constructor Summary
CanvasPeerImplSwing(java.lang.Object owner, DisplayMode displayMode, DisplayMode.FullscreenMode fullscreen, boolean vsync, FSAA fsaa, int depthBufferSize)
           
 
Method Summary
 void beforeThreadChanged()
          This method should be executed by the Thread that starts the actual rendering Thread right before it starts it.
 void clear()
          Clears the screen to BLACK.
 void destroy()
          Clears the screen (BLACK) and destroys the display.
 void display(javax.media.opengl.GLAutoDrawable drawable)
          
 void displayChanged(javax.media.opengl.GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
          
 java.awt.Component getComponent()
          
 javax.media.opengl.GLJPanel getDrawable()
           
 javax.media.opengl.GL getGL()
           
 int getHeight()
          Gets the width in an implementation independant manner
 org.jagatoo.input.impl.mixed.AWTJInputInputDeviceFactory getInputDeviceFactory(org.jagatoo.input.InputSystem inputSystem)
           
 int getLeft()
          Gets the left-location in an implementation independant manner
 java.lang.String getTitle()
          Gets the title in an implementation independant manner
 int getTop()
          Gets the top-location in an implementation independant manner
 OpenGLLayer getType()
          
 int getWidth()
          Gets the width in an implementation independant manner
 java.awt.Window getWindow()
          
 void init(javax.media.opengl.GLAutoDrawable drawable)
          
protected  java.lang.Object initRenderingImpl(View view, java.util.List<RenderPass> renderPasses, boolean layeredMode, long frameId, long nanoTime, long nanoStep, PickRequest pickRequest)
          Initializes the rendering.
 boolean isRendering()
          This flag is set by the Rendering system triggered by xith or by the CanvasPeer implementation itself (e.g when the CanvasPeer is auto-redrawn).
 boolean receivesInputEvents()
           
 void refreshCursor(org.jagatoo.input.devices.Mouse mouse)
           
 void reshape(javax.media.opengl.GLAutoDrawable drawable, int x, int y, int width, int height)
          
protected  void setAutoSwapBufferMode(boolean mode)
           
protected  boolean setDisplayModeImpl(DisplayMode displayMode)
          Sets the new DisplayMode in an implementation independant manner.
 void setGamma(float gamma, float brightness, float contrast)
          Changes the gamma-, brightness- and contrast values for this CanvasPeer.
 void setIcon(java.net.URL iconResource)
          Changes the window icon.
 boolean setLocation(int x, int y)
          Sets the location in an implementation independant manner.
 boolean setSize(int width, int height)
          Sets the size in an implementation independant manner.
 void setTitle(java.lang.String title)
          Sets the title in an implementation independant manner.
 void setVSyncEnabled(boolean vsync)
          Enables or disables V-Sync.
 
Methods inherited from class org.xith3d.render.jsr231.CanvasPeerImplBase
addDestroyableObject, beforeRenderStart, createRenderPeer, doRender, getCurrentViewport, getExpectedNativeDisplayModeClass, getMaxViewport, getRenderedFrames, getRenderPeer, getSwapInterval, init, isInitialized, setSwapInterval, updateViewport
 
Methods inherited from class org.xith3d.render.CanvasPeer
addTriangles, addWindowClosingListener, destroyGLNames, fireClosingEvent, getBPP, getBrightness, getCanvas3D, getCanvasID, getContrast, getCursor, getDepthBufferSize, getDisplayMode, getFrequency, getFSAA, getFullscreenSwitchRequest, getGamma, getInputDeviceFactory, getMaxTextureSize, getMaxTextureUnits, getMaxVertexAttributes, getOpenGLCapabilities, getOpenGLInfo, getRenderLock, getTriangles, getViewport, isClosingListenerRegistered, isDestroyed, isFullscreen, isUndecorated, isVSyncEnabled, removeWindowClosingListener, resetFullscreenSwitchRequest, setCanvas3D, setCursor, setCursorImpl, setDepthBufferSize, setDisplayMode, setDisplayModeRef, setFullscreen, setOpenGLCapabilities, setTriangles, setViewport, takeScreenshot, takeScreenshot, takeScreenshot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CanvasPeerImplSwing

public CanvasPeerImplSwing(java.lang.Object owner,
                           DisplayMode displayMode,
                           DisplayMode.FullscreenMode fullscreen,
                           boolean vsync,
                           FSAA fsaa,
                           int depthBufferSize)
Method Detail

getInputDeviceFactory

public org.jagatoo.input.impl.mixed.AWTJInputInputDeviceFactory getInputDeviceFactory(org.jagatoo.input.InputSystem inputSystem)
Specified by:
getInputDeviceFactory in interface org.jagatoo.input.render.InputSourceWindow

getDrawable

public final javax.media.opengl.GLJPanel getDrawable()
Specified by:
getDrawable in interface org.jagatoo.input.render.InputSourceWindow

refreshCursor

public void refreshCursor(org.jagatoo.input.devices.Mouse mouse)
Specified by:
refreshCursor in interface org.jagatoo.input.render.InputSourceWindow

receivesInputEvents

public final boolean receivesInputEvents()
Specified by:
receivesInputEvents in interface org.jagatoo.input.render.InputSourceWindow

init

public final void init(javax.media.opengl.GLAutoDrawable drawable)

Specified by:
init in interface javax.media.opengl.GLEventListener

getType

public OpenGLLayer getType()

Specified by:
getType in class CanvasPeer
Returns:
an element of the OpenGLLayer enum.
See Also:
OpenGLLayer

setVSyncEnabled

public void setVSyncEnabled(boolean vsync)
Enables or disables V-Sync.

Overrides:
setVSyncEnabled in class CanvasPeer

getGL

public final javax.media.opengl.GL getGL()
Specified by:
getGL in class CanvasPeerImplBase

getWindow

public final java.awt.Window getWindow()

Specified by:
getWindow in class CanvasPeer
Returns:
the Window holding the Canvas.

getComponent

public final java.awt.Component getComponent()

Specified by:
getComponent in class CanvasPeer
Returns:
the Component holding the Canvas.

setIcon

public void setIcon(java.net.URL iconResource)
             throws java.io.IOException
Changes the window icon.

Specified by:
setIcon in class CanvasPeer
Parameters:
iconResource - the resource of the image for the new icon
Throws:
java.io.IOException

setTitle

public final void setTitle(java.lang.String title)
Sets the title in an implementation independant manner.

Specified by:
setTitle in class CanvasPeer

getTitle

public final java.lang.String getTitle()
Gets the title in an implementation independant manner

Specified by:
getTitle in class CanvasPeer

setLocation

public final boolean setLocation(int x,
                                 int y)
Sets the location in an implementation independant manner.

Specified by:
setLocation in class CanvasPeer

getLeft

public final int getLeft()
Gets the left-location in an implementation independant manner

Specified by:
getLeft in class CanvasPeer

getTop

public final int getTop()
Gets the top-location in an implementation independant manner

Specified by:
getTop in class CanvasPeer

setSize

public final boolean setSize(int width,
                             int height)
Sets the size in an implementation independant manner.

Specified by:
setSize in class CanvasPeer

getWidth

public final int getWidth()
Gets the width in an implementation independant manner

Specified by:
getWidth in interface org.jagatoo.input.render.InputSourceWindow
Specified by:
getWidth in class CanvasPeer

getHeight

public final int getHeight()
Gets the width in an implementation independant manner

Specified by:
getHeight in interface org.jagatoo.input.render.InputSourceWindow
Specified by:
getHeight in class CanvasPeer

setDisplayModeImpl

protected boolean setDisplayModeImpl(DisplayMode displayMode)
Sets the new DisplayMode in an implementation independant manner.

Specified by:
setDisplayModeImpl in class CanvasPeer

reshape

public final void reshape(javax.media.opengl.GLAutoDrawable drawable,
                          int x,
                          int y,
                          int width,
                          int height)

Specified by:
reshape in interface javax.media.opengl.GLEventListener

setGamma

public void setGamma(float gamma,
                     float brightness,
                     float contrast)
Changes the gamma-, brightness- and contrast values for this CanvasPeer.

Overrides:
setGamma in class CanvasPeer
Parameters:
gamma - the gamma value
brightness - the brightness value [-1.0, +1.0]
contrast - the contrast value [0, +1.0]

displayChanged

public final void displayChanged(javax.media.opengl.GLAutoDrawable drawable,
                                 boolean modeChanged,
                                 boolean deviceChanged)

Specified by:
displayChanged in interface javax.media.opengl.GLEventListener

setAutoSwapBufferMode

protected void setAutoSwapBufferMode(boolean mode)
Specified by:
setAutoSwapBufferMode in class CanvasPeerImplBase

isRendering

public final boolean isRendering()
This flag is set by the Rendering system triggered by xith or by the CanvasPeer implementation itself (e.g when the CanvasPeer is auto-redrawn).

Specified by:
isRendering in class CanvasPeer

beforeThreadChanged

public void beforeThreadChanged()
This method should be executed by the Thread that starts the actual rendering Thread right before it starts it. (LWJGL needs this)

Specified by:
beforeThreadChanged in class CanvasPeer

display

public final void display(javax.media.opengl.GLAutoDrawable drawable)

Specified by:
display in interface javax.media.opengl.GLEventListener

initRenderingImpl

protected java.lang.Object initRenderingImpl(View view,
                                             java.util.List<RenderPass> renderPasses,
                                             boolean layeredMode,
                                             long frameId,
                                             long nanoTime,
                                             long nanoStep,
                                             PickRequest pickRequest)
Initializes the rendering. The CanvasPeer implementation may decide when to actually do.

Specified by:
initRenderingImpl in class CanvasPeer
Parameters:
view - the View used to render
renderPasses - the List of RenderPasses to iterate and render
layeredMode - if true, the RenderPasses are handled in layered mode
frameId - the current frame's id
pickRequest - null for normal rendering

clear

public void clear()
Clears the screen to BLACK.

Overrides:
clear in class CanvasPeerImplBase

destroy

public void destroy()
Clears the screen (BLACK) and destroys the display.

Overrides:
destroy in class CanvasPeer