com.jme.system.lwjgl
Class LWJGLDisplaySystem

java.lang.Object
  extended bycom.jme.system.DisplaySystem
      extended bycom.jme.system.lwjgl.LWJGLDisplaySystem

public class LWJGLDisplaySystem
extends DisplaySystem

LWJGLDisplaySystem defines an implementation of DisplaySystem that uses the LWJGL API for window creation and rendering via OpenGL. LWJGLRenderer is also created that gives a way of displaying data to the created window.

Version:
$Id: LWJGLDisplaySystem.java,v 1.24 2005/04/05 23:45:44 renanse Exp $
Author:
Mark Powell, Gregg Patton, Joshua Slack - Optimizations and Headless rendering

Field Summary
 
Fields inherited from class com.jme.system.DisplaySystem
alphaBits, bpp, created, depthBits, frq, fs, height, rendererNames, samples, stencilBits, width
 
Constructor Summary
LWJGLDisplaySystem()
          Constructor instantiates a new LWJGLDisplaySystem object.
 
Method Summary
 void close()
          close shutdowns and destroys any window contexts.
 java.awt.Canvas createCanvas(int w, int h)
          createCanvas will create an AWTGLCanvas context.
 void createHeadlessWindow(int w, int h, int bpp)
          createHeadlessWindow will create a headless LWJGL display context.
 TextureRenderer createTextureRenderer(int width, int height, boolean useRGB, boolean useRGBA, boolean useDepth, boolean isRectangle, int target, int mipmaps)
          createTextureRenderer builds the renderer used to render to a texture.
 void createWindow(int w, int h, int bpp, int frq, boolean fs)
          createWindow will create a LWJGL display context.
 WidgetFont getFont(java.lang.String fontName)
           
 org.lwjgl.opengl.Pbuffer getHeadlessDisplay()
          Returns the Pbuffer used for headless display or null if not headless.
 Renderer getRenderer()
          getRenderer returns the created rendering class for LWJGL ( LWJGLRenderer).
 RendererType getRendererType()
          getRendererType
 Vector3f getScreenCoordinates(Vector3f worldPosition)
          getScreenCoordinates translate world to screen coordinates.
 Vector3f getScreenCoordinates(Vector3f worldPosition, Vector3f store)
          getScreenCoordinates translate world to screen coordinates.
 Vector3f getWorldCoordinates(Vector2f screenPosition, float zPos)
          getWorldCoordinates translate screen to world coordinates.
 Vector3f getWorldCoordinates(Vector2f screenPosition, float zPos, Vector3f store)
          getWorldCoordinates translate screen to world coordinates.
 boolean isClosing()
          isClosing returns any close requests.
 boolean isValidDisplayMode(int width, int height, int bpp, int freq)
          isValidDisplayMode determines if the given parameters constitute a valid display mode on this system.
 void recreateWindow(int w, int h, int bpp, int frq, boolean fs)
          recreateWindow will recreate a LWJGL display context.
 void reset()
          reset prepares the window for closing or restarting.
 void setRenderer(Renderer r)
           
 void setTitle(java.lang.String title)
          setTitle sets the window title of the created window.
 void setVSyncEnabled(boolean enabled)
          setVSyncEnabled attempts to enable or disable monitor vertical synchronization.
 
Methods inherited from class com.jme.system.DisplaySystem
getBitDepth, getDisplaySystem, getDisplaySystem, getFrequency, getHeight, getMinAlphaBits, getMinDepthBits, getMinSamples, getMinStencilBits, getWidth, isCreated, isFullScreen, setMinAlphaBits, setMinDepthBits, setMinSamples, setMinStencilBits, updateStates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LWJGLDisplaySystem

public LWJGLDisplaySystem()
Constructor instantiates a new LWJGLDisplaySystem object. During instantiation confirmation is made to determine if the LWJGL API is installed properly. If not, a JmeException is thrown.

Method Detail

isValidDisplayMode

public boolean isValidDisplayMode(int width,
                                  int height,
                                  int bpp,
                                  int freq)
Description copied from class: DisplaySystem
isValidDisplayMode determines if the given parameters constitute a valid display mode on this system. Returning true does not necessarily guarantee that the system is capable of running in the specified display mode, merely that it believes it is possible.

Specified by:
isValidDisplayMode in class DisplaySystem
Parameters:
width - the width/horizontal resolution of the display.
height - the height/vertical resolution of the display.
bpp - the bit depth of the display.
freq - the frequency of refresh of the display (in Hz).
See Also:
DisplaySystem.isValidDisplayMode(int, int, int, int)

setVSyncEnabled

public void setVSyncEnabled(boolean enabled)
Description copied from class: DisplaySystem
setVSyncEnabled attempts to enable or disable monitor vertical synchronization. The method is a "best attempt" to change the monitor vertical refresh synchronization, and is not guaranteed to be successful.

Specified by:
setVSyncEnabled in class DisplaySystem
Parameters:
enabled - true to synchronize, false to ignore synchronization
See Also:
DisplaySystem.setVSyncEnabled(boolean)

setTitle

public void setTitle(java.lang.String title)
setTitle sets the window title of the created window.

Specified by:
setTitle in class DisplaySystem
Parameters:
title - the title.

createWindow

public void createWindow(int w,
                         int h,
                         int bpp,
                         int frq,
                         boolean fs)
createWindow will create a LWJGL display context. This window will be a purely native context as defined by the LWJGL API.

Specified by:
createWindow in class DisplaySystem
Parameters:
w - the width/horizontal resolution of the display.
h - the height/vertical resolution of the display.
bpp - the color depth of the display.
frq - the frequency of refresh of the display.
fs - flag determining if fullscreen is to be used or not. True will use fullscreen, false will use windowed mode.
See Also:
DisplaySystem.createWindow(int, int, int, int, boolean)

createHeadlessWindow

public void createHeadlessWindow(int w,
                                 int h,
                                 int bpp)
createHeadlessWindow will create a headless LWJGL display context. This window will be a purely native context as defined by the LWJGL API.

Specified by:
createHeadlessWindow in class DisplaySystem
Parameters:
w - the width/horizontal resolution of the display.
h - the height/vertical resolution of the display.
bpp - the color depth of the display.
See Also:
DisplaySystem.createHeadlessWindow(int, int, int)

createCanvas

public java.awt.Canvas createCanvas(int w,
                                    int h)
createCanvas will create an AWTGLCanvas context. This window will be a purely native context as defined by the LWJGL API.

Specified by:
createCanvas in class DisplaySystem
Parameters:
w - the width/horizontal resolution of the display.
h - the height/vertical resolution of the display.
See Also:
DisplaySystem.createCanvas(int, int)

getHeadlessDisplay

public org.lwjgl.opengl.Pbuffer getHeadlessDisplay()
Returns the Pbuffer used for headless display or null if not headless.

Returns:
Pbuffer

recreateWindow

public void recreateWindow(int w,
                           int h,
                           int bpp,
                           int frq,
                           boolean fs)
recreateWindow will recreate a LWJGL display context. This window will be a purely native context as defined by the LWJGL API. If a window is not already created, it calls createWindow and exits. Other wise it calls reinitDisplay and renderer.reinit(width,height)

Specified by:
recreateWindow in class DisplaySystem
Parameters:
w - the width/horizontal resolution of the display.
h - the height/vertical resolution of the display.
bpp - the color depth of the display.
frq - the frequency of refresh of the display.
fs - flag determining if fullscreen is to be used or not. True will use fullscreen, false will use windowed mode.
See Also:
DisplaySystem.recreateWindow(int, int, int, int, boolean)

getRenderer

public Renderer getRenderer()
getRenderer returns the created rendering class for LWJGL ( LWJGLRenderer). This will give the needed access to display data to the window.

Specified by:
getRenderer in class DisplaySystem
Returns:
the appropriate Renderer implementation that is compatible with the used DisplaySystem.
See Also:
DisplaySystem.getRenderer()

isClosing

public boolean isClosing()
isClosing returns any close requests. True if any exist, false otherwise.

Specified by:
isClosing in class DisplaySystem
Returns:
true if a close request is active.
See Also:
DisplaySystem.isClosing()

reset

public void reset()
reset prepares the window for closing or restarting.

Specified by:
reset in class DisplaySystem
See Also:
DisplaySystem.reset()

close

public void close()
Description copied from class: DisplaySystem
close shutdowns and destroys any window contexts.

Specified by:
close in class DisplaySystem

getFont

public WidgetFont getFont(java.lang.String fontName)
Specified by:
getFont in class DisplaySystem
Parameters:
fontName - - name of the font to loaded
Returns:
an instance of the requested font, null of the isn't loaded.

getRendererType

public RendererType getRendererType()
getRendererType

Specified by:
getRendererType in class DisplaySystem
Returns:
@see com.jme.system.DisplaySystem#getRendererType()
See Also:
JmeType

createTextureRenderer

public TextureRenderer createTextureRenderer(int width,
                                             int height,
                                             boolean useRGB,
                                             boolean useRGBA,
                                             boolean useDepth,
                                             boolean isRectangle,
                                             int target,
                                             int mipmaps)
createTextureRenderer builds the renderer used to render to a texture.

Specified by:
createTextureRenderer in class DisplaySystem
Parameters:
width - width of texture
height - height of texture
useRGB - if this is true, useRGBA should not be
useRGBA - if this is true, useRGB should not be
useDepth -
isRectangle -
target -
mipmaps -
Returns:
A TextureRenderer for the display system.

getScreenCoordinates

public Vector3f getScreenCoordinates(Vector3f worldPosition)
getScreenCoordinates translate world to screen coordinates. Written by Marius, rewritten for LWJGL .9 by Joshua Slack.

Specified by:
getScreenCoordinates in class DisplaySystem
Parameters:
worldPosition - the world position to translate.
Returns:
the screen position.

getScreenCoordinates

public Vector3f getScreenCoordinates(Vector3f worldPosition,
                                     Vector3f store)
getScreenCoordinates translate world to screen coordinates. Written by Marius, rewritten for LWJGL .9 by Joshua Slack.

Specified by:
getScreenCoordinates in class DisplaySystem
Parameters:
worldPosition - the world position to translate.
store - Vector3f to store the world position in.
Returns:
the screen position.

getWorldCoordinates

public Vector3f getWorldCoordinates(Vector2f screenPosition,
                                    float zPos)
getWorldCoordinates translate screen to world coordinates. Written by Marius, rewritten for lwjgl .9 by Joshua Slack.

Specified by:
getWorldCoordinates in class DisplaySystem
Parameters:
screenPosition - the screen coordinates to translate.
zPos - between 0 and 1.
Returns:
world position pointed to by screen coordinate.

getWorldCoordinates

public Vector3f getWorldCoordinates(Vector2f screenPosition,
                                    float zPos,
                                    Vector3f store)
getWorldCoordinates translate screen to world coordinates. Written by Marius, rewritten for lwjgl .9 by Jashua Slack.

Specified by:
getWorldCoordinates in class DisplaySystem
Parameters:
screenPosition - the screen coordinates to translate.
zPos - between 0 and 1.
store - Vector3f The vector to store the result in.
Returns:
world position pointed to by screen coordinate.

setRenderer

public void setRenderer(Renderer r)
Specified by:
setRenderer in class DisplaySystem