com.threerings.opengl
Class GlApp

java.lang.Object
  extended by com.threerings.expr.DynamicScope
      extended by com.threerings.opengl.GlApp
All Implemented Interfaces:
EditorContext, Scope, ScopeUpdateListener, AlContext, Enqueueable, GlContext
Direct Known Subclasses:
GlCanvasApp, GlDisplayApp

public abstract class GlApp
extends DynamicScope
implements GlContext, EditorContext, Enqueueable

A base class for OpenGL-based applications.


Field Summary
protected  Vector3f _at
          Used to compute listener orientation.
protected  Quaternion _billboardRotation
          The view rotation shared by all billboards aligned with the z axis and the view vector.
protected  CameraHandler _camhand
          The camera handler.
protected  ConfigManager _cfgmgr
          The configuration manager.
protected  ClipProvider _clipprov
          The clip provider.
protected  ColorPository _colorpos
          The color pository.
protected  boolean _compatibilityMode
          Controls whether certain features are disabled for maximum compatibility.
protected  Compositor _compositor
          The view compositor.
protected  MutableLong _epoch
          A container for the application epoch.
protected  ImageCache _imgcache
          The image cache.
protected  MessageManager _msgmgr
          The message manager.
protected  MutableLong _now
          A container for the current time as sampled at the beginning of the frame.
protected  boolean _renderEffects
          Controls whether render effects are enabled.
protected  Renderer _renderer
          The OpenGL renderer.
protected  String _renderScheme
          The base render scheme (used to select material techniques).
protected  ResourceManager _rsrcmgr
          The resource manager.
protected  ShaderCache _shadcache
          The shader cache.
protected  SoundManager _soundmgr
          The sound manager.
protected  MutableFloat _streamGain
          A container for the global stream gain.
protected  Vector3f _up
          Used to compute listener orientation.
protected  Transform3D _viewTransform
          A scoped reference to the root view transform.
protected  TransformState _viewTransformState
          A transform state containing the camera's view transform.
protected  Transform3D _worldTransform
          A scoped reference to the root world transform.
protected static PixelFormat[] PIXEL_FORMATS
          Our supported pixel formats in order of preference.
 
Fields inherited from class com.threerings.expr.DynamicScope
_compoundDepth, _listeners, _owner, _parentScope, _scopeName, _symbols, INVALID_SCOPE
 
Fields inherited from interface com.threerings.expr.Scope
EPOCH, NOW
 
Constructor Summary
GlApp()
           
 
Method Summary
protected  void compositeView()
          Gives the application a chance to composite anything it might want rendered.
protected  CameraHandler createCameraHandler()
          Creates and returns the camera handler.
abstract  Root createRoot()
          Creates a user interface root appropriate for this application.
 BufferedImage createSnapshot()
          Creates and returns a snapshot image of the current frame.
protected  void didInit()
          Override to perform custom initialization after the render context is valid.
 void enqueue()
          Enqueues this object for rendering.
 GlApp getApp()
          Returns a reference to the application object.
 CameraHandler getCameraHandler()
          Returns a reference to the camera handler.
 ClipProvider getClipProvider()
          Returns a reference to the clip provider.
 ColorPository getColorPository()
          Returns a reference to the color pository.
 boolean getCompatibilityMode()
          Checks whether compatibility mode is enabled.
 Compositor getCompositor()
          Returns a reference to the compositor.
 ConfigManager getConfigManager()
          Returns a reference to the configuration manager.
 ImageCache getImageCache()
          Returns a reference to the image cache.
 MessageManager getMessageManager()
          Returns a reference to the message manager.
 boolean getRenderEffects()
          Checks whether render effects are enabled.
 Renderer getRenderer()
          Returns a reference to the renderer.
 String getRenderScheme()
          Returns the name of the configured render scheme.
 ResourceManager getResourceManager()
          Returns a reference to the resource manager.
abstract  RunQueue getRunQueue()
          Returns a reference to the application's run queue.
 DynamicScope getScope()
          Returns a reference to the scope.
 ShaderCache getShaderCache()
          Returns a reference to the shader cache.
 SoundManager getSoundManager()
          Returns a reference to the sound manager.
 MutableFloat getStreamGain()
          Returns a reference to the stream gain.
protected  void init()
          Initializes the view once the OpenGL context is available.
protected abstract  void initRenderer()
          Initializes the renderer.
protected  void initSharedManagers()
          Initializes the references to the resource manager, config manager, and color pository.
protected  void renderView()
          Renders the entire view.
 void setCameraHandler(CameraHandler camhand)
          Sets the camera handler reference.
 void setCompatibilityMode(boolean enabled)
          Enables or disables compatibility mode, which disables certain features for maximum compatibility.
 void setRenderEffects(boolean enabled)
          Enables or disables render effects.
 void setRenderer(Renderer renderer)
          Sets the renderer reference.
 void setRenderScheme(String scheme)
          Sets the render scheme.
protected  boolean shouldCheckTimestamps()
          Determines whether or not we should check resource file timestamps when we load them from the cache (in other words, whether we expect the files to be modified externally).
abstract  void shutdown()
          Shuts down the application.
abstract  void startup()
          Starts up the application.
protected  void updateView()
          Performs any updates that are necessary even when not rendering.
protected  void updateView(float elapsed)
          Performs any updates that are necessary even when not rendering.
protected  void willShutdown()
          Override to perform cleanup before the application exits.
 String xlate(String bundle, String msg)
          Convenience method for translation.
 
Methods inherited from class com.threerings.expr.DynamicScope
addListener, dispose, endCompoundUpdate, get, getParentScope, getScopeName, put, remove, removeListener, scopeUpdated, setParentScope, startCompoundUpdate, wasUpdated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.threerings.opengl.util.GlContext
makeCurrent
 

Field Detail

_renderer

protected Renderer _renderer
The OpenGL renderer.


_compositor

protected Compositor _compositor
The view compositor.


_camhand

protected CameraHandler _camhand
The camera handler.


_rsrcmgr

protected ResourceManager _rsrcmgr
The resource manager.


_msgmgr

protected MessageManager _msgmgr
The message manager.


_cfgmgr

protected ConfigManager _cfgmgr
The configuration manager.


_colorpos

protected ColorPository _colorpos
The color pository.


_imgcache

protected ImageCache _imgcache
The image cache.


_shadcache

protected ShaderCache _shadcache
The shader cache.


_soundmgr

protected SoundManager _soundmgr
The sound manager.


_clipprov

protected ClipProvider _clipprov
The clip provider.


_now

@Scoped
protected MutableLong _now
A container for the current time as sampled at the beginning of the frame.


_epoch

@Scoped
protected MutableLong _epoch
A container for the application epoch.


_renderScheme

@Scoped
protected String _renderScheme
The base render scheme (used to select material techniques).


_compatibilityMode

@Scoped
protected boolean _compatibilityMode
Controls whether certain features are disabled for maximum compatibility.


_renderEffects

@Scoped
protected boolean _renderEffects
Controls whether render effects are enabled.


_viewTransform

@Scoped
protected Transform3D _viewTransform
A scoped reference to the root view transform.


_worldTransform

@Scoped
protected Transform3D _worldTransform
A scoped reference to the root world transform.


_viewTransformState

@Scoped
protected TransformState _viewTransformState
A transform state containing the camera's view transform.


_billboardRotation

@Scoped
protected Quaternion _billboardRotation
The view rotation shared by all billboards aligned with the z axis and the view vector.


_streamGain

@Scoped
protected MutableFloat _streamGain
A container for the global stream gain.


_at

protected Vector3f _at
Used to compute listener orientation.


_up

protected Vector3f _up
Used to compute listener orientation.


PIXEL_FORMATS

protected static final PixelFormat[] PIXEL_FORMATS
Our supported pixel formats in order of preference.

Constructor Detail

GlApp

public GlApp()
Method Detail

getRunQueue

public abstract RunQueue getRunQueue()
Returns a reference to the application's run queue.


setRenderScheme

public void setRenderScheme(String scheme)
Sets the render scheme.


getRenderScheme

public String getRenderScheme()
Returns the name of the configured render scheme.


setCompatibilityMode

public void setCompatibilityMode(boolean enabled)
Enables or disables compatibility mode, which disables certain features for maximum compatibility.


getCompatibilityMode

public boolean getCompatibilityMode()
Checks whether compatibility mode is enabled.


setRenderEffects

public void setRenderEffects(boolean enabled)
Enables or disables render effects.


getRenderEffects

public boolean getRenderEffects()
Checks whether render effects are enabled.


getStreamGain

public MutableFloat getStreamGain()
Returns a reference to the stream gain.


createRoot

public abstract Root createRoot()
Creates a user interface root appropriate for this application.


startup

public abstract void startup()
Starts up the application.


shutdown

public abstract void shutdown()
Shuts down the application.


xlate

public String xlate(String bundle,
                    String msg)
Convenience method for translation.


createSnapshot

public BufferedImage createSnapshot()
Creates and returns a snapshot image of the current frame.


getApp

public GlApp getApp()
Description copied from interface: GlContext
Returns a reference to the application object.

Specified by:
getApp in interface GlContext

getScope

public DynamicScope getScope()
Description copied from interface: GlContext
Returns a reference to the scope.

Specified by:
getScope in interface AlContext
Specified by:
getScope in interface GlContext

getResourceManager

public ResourceManager getResourceManager()
Description copied from interface: GlContext
Returns a reference to the resource manager.

Specified by:
getResourceManager in interface EditorContext
Specified by:
getResourceManager in interface AlContext
Specified by:
getResourceManager in interface GlContext

getConfigManager

public ConfigManager getConfigManager()
Description copied from interface: GlContext
Returns a reference to the configuration manager.

Specified by:
getConfigManager in interface EditorContext
Specified by:
getConfigManager in interface AlContext
Specified by:
getConfigManager in interface GlContext

getSoundManager

public SoundManager getSoundManager()
Description copied from interface: AlContext
Returns a reference to the sound manager.

Specified by:
getSoundManager in interface AlContext

getClipProvider

public ClipProvider getClipProvider()
Description copied from interface: AlContext
Returns a reference to the clip provider.

Specified by:
getClipProvider in interface AlContext

setRenderer

public void setRenderer(Renderer renderer)
Description copied from interface: GlContext
Sets the renderer reference.

Specified by:
setRenderer in interface GlContext

getRenderer

public Renderer getRenderer()
Description copied from interface: GlContext
Returns a reference to the renderer.

Specified by:
getRenderer in interface GlContext

getCompositor

public Compositor getCompositor()
Description copied from interface: GlContext
Returns a reference to the compositor.

Specified by:
getCompositor in interface GlContext

setCameraHandler

public void setCameraHandler(CameraHandler camhand)
Description copied from interface: GlContext
Sets the camera handler reference.

Specified by:
setCameraHandler in interface GlContext

getCameraHandler

public CameraHandler getCameraHandler()
Description copied from interface: GlContext
Returns a reference to the camera handler.

Specified by:
getCameraHandler in interface GlContext

getMessageManager

public MessageManager getMessageManager()
Description copied from interface: GlContext
Returns a reference to the message manager.

Specified by:
getMessageManager in interface EditorContext
Specified by:
getMessageManager in interface GlContext

getColorPository

public ColorPository getColorPository()
Description copied from interface: GlContext
Returns a reference to the color pository.

Specified by:
getColorPository in interface EditorContext
Specified by:
getColorPository in interface GlContext

getImageCache

public ImageCache getImageCache()
Description copied from interface: GlContext
Returns a reference to the image cache.

Specified by:
getImageCache in interface GlContext

getShaderCache

public ShaderCache getShaderCache()
Description copied from interface: GlContext
Returns a reference to the shader cache.

Specified by:
getShaderCache in interface GlContext

enqueue

public void enqueue()
Description copied from interface: Enqueueable
Enqueues this object for rendering.

Specified by:
enqueue in interface Enqueueable

initSharedManagers

protected void initSharedManagers()
Initializes the references to the resource manager, config manager, and color pository. By default this creates new managers, but it may be overridden to copy references to existing ones.


shouldCheckTimestamps

protected boolean shouldCheckTimestamps()
Determines whether or not we should check resource file timestamps when we load them from the cache (in other words, whether we expect the files to be modified externally).


init

protected void init()
Initializes the view once the OpenGL context is available.


initRenderer

protected abstract void initRenderer()
Initializes the renderer.


createCameraHandler

protected CameraHandler createCameraHandler()
Creates and returns the camera handler.


didInit

protected void didInit()
Override to perform custom initialization after the render context is valid.


willShutdown

protected void willShutdown()
Override to perform cleanup before the application exits.


updateView

protected void updateView()
Performs any updates that are necessary even when not rendering.


updateView

protected void updateView(float elapsed)
Performs any updates that are necessary even when not rendering.

Parameters:
elapsed - the elapsed time since the last update, in seconds.

renderView

protected void renderView()
Renders the entire view.


compositeView

protected void compositeView()
Gives the application a chance to composite anything it might want rendered.