de.matthiasmann.twl.renderer
Interface Renderer

All Known Implementing Classes:
LWJGLRenderer

public interface Renderer

TWL Rendering interface


Method Summary
 void clipEnter(int x, int y, int w, int h)
          Enters a clip region.
 void clipEnter(Rect rect)
          Enters a clip region.
 boolean clipIsEmpty()
          Checks if the active clip region is empty (nothing will render).
 void clipLeave()
          Leaves a clip region creeated by #clipEnter
 DynamicImage createDynamicImage(int width, int height)
          Creates a dynamic image with undefined content.
 Image createGradient(Gradient gradient)
           
 CacheContext createNewCacheContext()
          Creates a new cache context.
 void endRendering()
          Clean up after rendering TWL.
 CacheContext getActiveCacheContext()
          Returns the active cache context.
 FontMapper getFontMapper()
          Returns the font mapper object if one is available.
 int getHeight()
          Returns the height of the renderable surface
 Input getInput()
          Returns the polled input object for this renderer target.
 LineRenderer getLineRenderer()
          Returns the line renderer.
 OffscreenRenderer getOffscreenRenderer()
          Returns the offscreen renderer.
 long getTimeMillis()
          Returns the elapsed time in milliseconds.
 int getWidth()
          Returns the width of the renderable surface
 Font loadFont(java.net.URL baseUrl, StateSelect select, FontParameter... parameterList)
          Loads a font.
 Texture loadTexture(java.net.URL url, java.lang.String format, java.lang.String filter)
          Loads a texture.
 void popGlobalTintColor()
           
 void pushGlobalTintColor(float r, float g, float b, float a)
          Pushes a new tint color on the tint stack.
 void setActiveCacheContext(CacheContext cc)
          Sets the active cache context.
 void setCursor(MouseCursor cursor)
           
 void setMouseButton(int button, boolean state)
          Sets the mouse button state for SW mouse cursor rendering
 void setMousePosition(int mouseX, int mouseY)
          Sets the mouse position for SW mouse cursor rendering
 boolean startRendering()
          Setup rendering for TWL.
 

Method Detail

getTimeMillis

long getTimeMillis()
Returns the elapsed time in milliseconds.

Returns:
the elapsed time in milliseconds.

getInput

Input getInput()
Returns the polled input object for this renderer target.

When using the "push" method for input event generation return null.

Returns:
the Input object or null if none is available/used.

startRendering

boolean startRendering()
Setup rendering for TWL.

Must be called before any Font or Image objects is drawn.

When this method returned true then endRendering() must be called.

Returns:
true if rendering was started, false otherwise

endRendering

void endRendering()
Clean up after rendering TWL. Only call this method when startRendering() returned true


getWidth

int getWidth()
Returns the width of the renderable surface

Returns:
the width of the renderable surface

getHeight

int getHeight()
Returns the height of the renderable surface

Returns:
the height of the renderable surface

createNewCacheContext

CacheContext createNewCacheContext()
Creates a new cache context. Call setActiveCacheContext to activate it.

Returns:
a new CacheContext
See Also:
setActiveCacheContext(de.matthiasmann.twl.renderer.CacheContext)

setActiveCacheContext

void setActiveCacheContext(CacheContext cc)
                           throws java.lang.IllegalStateException
Sets the active cache context. It will be used for all future load operations.

Parameters:
cc - The CacheContext object
Throws:
java.lang.NullPointerException - when cc is null
java.lang.IllegalStateException - when the CacheContext object is invalid

getActiveCacheContext

CacheContext getActiveCacheContext()
Returns the active cache context. If no valid cache context is active then a new one is created and activated.

Returns:
the active CacheContext object

loadFont

Font loadFont(java.net.URL baseUrl,
              StateSelect select,
              FontParameter... parameterList)
              throws java.io.IOException
Loads a font.

Parameters:
baseUrl - the base URL that can be used to load font data
select - the StateSelect object
parameterList - the font parameters - must be exactly 1 more then the number of expressions in the select object
Returns:
a Font object
Throws:
java.io.IOException - if the font could not be loaded
java.lang.NullPointerException - when one of the parameters is null
java.lang.IllegalArgumentException - when the number of font parameters doesn't match the number of state expressions

loadTexture

Texture loadTexture(java.net.URL url,
                    java.lang.String format,
                    java.lang.String filter)
                    throws java.io.IOException
Loads a texture. Textures are used to create images.

Parameters:
url - the URL of the texture file
format - a format description - depends on the implementation
filter - how the texture should be filtered - should support "nearest" and linear"
Returns:
a Texture object
Throws:
java.io.IOException - if the texture could not be loaded

getLineRenderer

LineRenderer getLineRenderer()
Returns the line renderer. If line rendering is not supported then this method returns null. This is an optional operation.

Returns:
the line renderer or null if not supported.

getOffscreenRenderer

OffscreenRenderer getOffscreenRenderer()
Returns the offscreen renderer. If offscreen rendering is not supported then this method returns null. This is an optional operation.

Returns:
the offscreen renderer or null if not supported.

getFontMapper

FontMapper getFontMapper()
Returns the font mapper object if one is available. This is an optional operation.

Returns:
the font mapper or null if not supported.

createDynamicImage

DynamicImage createDynamicImage(int width,
                                int height)
Creates a dynamic image with undefined content. This is an optional operation.

Parameters:
width - the width of the image
height - the height of the image
Returns:
a new dynamic image or null if the image could not be created

createGradient

Image createGradient(Gradient gradient)

clipEnter

void clipEnter(int x,
               int y,
               int w,
               int h)
Enters a clip region. The new clip region is the intersection of the current clip region with the specified coordinates.

Parameters:
x - the left edge
y - the top edge
w - the width
h - the height

clipEnter

void clipEnter(Rect rect)
Enters a clip region. The new clip region is the intersection of the current clip region with the specified coordinates.

Parameters:
rect - the coordinates

clipIsEmpty

boolean clipIsEmpty()
Checks if the active clip region is empty (nothing will render).

Returns:
true if the active clip region is empty

clipLeave

void clipLeave()
Leaves a clip region creeated by #clipEnter

See Also:
clipEnter(int, int, int, int), clipEnter(de.matthiasmann.twl.Rect)

setCursor

void setCursor(MouseCursor cursor)

setMousePosition

void setMousePosition(int mouseX,
                      int mouseY)
Sets the mouse position for SW mouse cursor rendering

Parameters:
mouseX - X mouse position
mouseY - Y mouse position

setMouseButton

void setMouseButton(int button,
                    boolean state)
Sets the mouse button state for SW mouse cursor rendering

Parameters:
button - the mouse button
state - true if the mouse button is pressed
See Also:
Event.MOUSE_LBUTTON, Event.MOUSE_MBUTTON, Event.MOUSE_RBUTTON

pushGlobalTintColor

void pushGlobalTintColor(float r,
                         float g,
                         float b,
                         float a)
Pushes a new tint color on the tint stack. The current tint color is multiplied by the new tint color. For every call of pushGlobalTintColor a call to popGlobalTintColor must be made.

Parameters:
r - red, must be 0.0f <= r <= 1.0f
g - green, must be 0.0f <= g <= 1.0f
b - blue, must be 0.0f <= b <= 1.0f
a - alpha, must be 0.0f <= a <= 1.0f

popGlobalTintColor

void popGlobalTintColor()