Packagestarling.core
Classpublic class RenderSupport
InheritanceRenderSupport Inheritance Object

A class that contains helper methods simplifying Stage3D rendering. A RenderSupport instance is passed to any "render" method of display objects. It allows manipulation of the current transformation matrix (similar to the matrix manipulation methods of OpenGL 1.x) and other helper methods.



Public Properties
 PropertyDefined By
  backBufferHeight : int
The height of the back buffer, as it was configured in the last call to 'RenderSupport.configureBackBuffer()'.
RenderSupport
  backBufferWidth : int
The width of the back buffer, as it was configured in the last call to 'RenderSupport.configureBackBuffer()'.
RenderSupport
  blendMode : String
The blend mode to be used on rendering.
RenderSupport
  drawCount : int
[read-only] Indicates the number of stage3D draw calls.
RenderSupport
  modelViewMatrix : Matrix
[read-only] Returns the current modelview matrix.
RenderSupport
  mvpMatrix : Matrix
[read-only] Calculates the product of modelview and projection matrix.
RenderSupport
  mvpMatrix3D : Matrix3D
[read-only] Calculates the product of modelview and projection matrix and saves it in a 3D matrix.
RenderSupport
  projectionMatrix : Matrix
[read-only] Returns the current projection matrix.
RenderSupport
  renderTarget : Texture
The texture that is currently being rendered into, or 'null' to render into the back buffer.
RenderSupport
  scissorRectangle : Rectangle
The scissor rectangle can be used to limit rendering in the current render target to a certain area.
RenderSupport
Public Methods
 MethodDefined By
  
Creates a new RenderSupport object with an empty matrix stack.
RenderSupport
  
applyBlendMode(premultipliedAlpha:Boolean):void
Activates the current blend mode on the active rendering context.
RenderSupport
  
assembleAgal(vertexShader:String, fragmentShader:String, resultProgram:Program3D = null):Program3D
[static] Assembles fragment- and vertex-shaders, passed as Strings, to a Program3D.
RenderSupport
  
batchQuad(quad:Quad, parentAlpha:Number, texture:Texture = null, smoothing:String = null):void
Adds a quad to the current batch of unrendered quads.
RenderSupport
  
clear(rgb:uint = 0, alpha:Number = 0.0):void
Clears the render context with a certain color and alpha value.
RenderSupport
  
clear(rgb:uint = 0, alpha:Number = 0.0):void
[static] Clears the render context with a certain color and alpha value.
RenderSupport
  
configureBackBuffer(width:int, height:int, antiAlias:int, enableDepthAndStencil:Boolean):void
Configures the back buffer on the current context3D.
RenderSupport
  
dispose():void
Disposes all quad batches.
RenderSupport
  
Renders the current quad batch and resets it.
RenderSupport
  
Changes the modelview matrix to the identity matrix.
RenderSupport
  
nextFrame():void
Resets matrix stack, blend mode, quad batch index, and draw count.
RenderSupport
  
popMatrix():void
Restores the modelview matrix that was last pushed to the stack.
RenderSupport
  
prependMatrix(matrix:Matrix):void
Prepends a matrix to the modelview matrix by multiplying it another matrix.
RenderSupport
  
pushMatrix():void
Pushes the current modelview matrix to a stack from which it can be restored later.
RenderSupport
  
raiseDrawCount(value:uint = 1):void
Raises the draw count by a specific value.
RenderSupport
  
Empties the matrix stack, resets the modelview matrix to the identity matrix.
RenderSupport
  
rotateMatrix(angle:Number):void
Prepends a rotation (angle in radians) to the modelview matrix.
RenderSupport
  
scaleMatrix(sx:Number, sy:Number):void
Prepends an incremental scale change to the modelview matrix.
RenderSupport
  
setBlendFactors(premultipliedAlpha:Boolean, blendMode:String = normal):void
[static] Sets up the blending factors that correspond with a certain blend mode.
RenderSupport
  
setDefaultBlendFactors(premultipliedAlpha:Boolean):void
[static] Deprecated.
RenderSupport
  
setOrthographicProjection(x:Number, y:Number, width:Number, height:Number):void
Sets up the projection matrix for ortographic 2D rendering.
RenderSupport
  
Prepends translation, scale and rotation of an object to the modelview matrix.
RenderSupport
  
transformMatrixForObject(matrix:Matrix, object:DisplayObject):void
[static] Prepends translation, scale and rotation of an object to a custom matrix.
RenderSupport
  
translateMatrix(dx:Number, dy:Number):void
Prepends a translation to the modelview matrix.
RenderSupport
Property Detail
backBufferHeightproperty
backBufferHeight:int

The height of the back buffer, as it was configured in the last call to 'RenderSupport.configureBackBuffer()'. Beware: changing this value does not actually resize the back buffer; the setter should only be used to inform Starling about the size of a back buffer it can't control (shared context situations).


Implementation
    public function get backBufferHeight():int
    public function set backBufferHeight(value:int):void
backBufferWidthproperty 
backBufferWidth:int

The width of the back buffer, as it was configured in the last call to 'RenderSupport.configureBackBuffer()'. Beware: changing this value does not actually resize the back buffer; the setter should only be used to inform Starling about the size of a back buffer it can't control (shared context situations).


Implementation
    public function get backBufferWidth():int
    public function set backBufferWidth(value:int):void
blendModeproperty 
blendMode:String

The blend mode to be used on rendering. To apply the factor, you have to manually call 'applyBlendMode' (because the actual blend factors depend on the PMA mode).


Implementation
    public function get blendMode():String
    public function set blendMode(value:String):void
drawCountproperty 
drawCount:int  [read-only]

Indicates the number of stage3D draw calls.


Implementation
    public function get drawCount():int
modelViewMatrixproperty 
modelViewMatrix:Matrix  [read-only]

Returns the current modelview matrix. CAUTION: not a copy -- use with care!


Implementation
    public function get modelViewMatrix():Matrix
mvpMatrixproperty 
mvpMatrix:Matrix  [read-only]

Calculates the product of modelview and projection matrix. CAUTION: Don't save a reference to this object! Each call returns the same instance.


Implementation
    public function get mvpMatrix():Matrix
mvpMatrix3Dproperty 
mvpMatrix3D:Matrix3D  [read-only]

Calculates the product of modelview and projection matrix and saves it in a 3D matrix. CAUTION: Don't save a reference to this object! Each call returns the same instance.


Implementation
    public function get mvpMatrix3D():Matrix3D
projectionMatrixproperty 
projectionMatrix:Matrix  [read-only]

Returns the current projection matrix. CAUTION: not a copy -- use with care!


Implementation
    public function get projectionMatrix():Matrix
renderTargetproperty 
renderTarget:Texture

The texture that is currently being rendered into, or 'null' to render into the back buffer. If you set a new target, it is immediately activated.


Implementation
    public function get renderTarget():Texture
    public function set renderTarget(value:Texture):void
scissorRectangleproperty 
scissorRectangle:Rectangle

The scissor rectangle can be used to limit rendering in the current render target to a certain area. This method expects the rectangle in stage coordinates (different to the context3D method with the same name, which expects pixels). Pass null to turn off scissoring. CAUTION: not a copy -- use with care!


Implementation
    public function get scissorRectangle():Rectangle
    public function set scissorRectangle(value:Rectangle):void
Constructor Detail
RenderSupport()Constructor
public function RenderSupport()

Creates a new RenderSupport object with an empty matrix stack.

Method Detail
applyBlendMode()method
public function applyBlendMode(premultipliedAlpha:Boolean):void

Activates the current blend mode on the active rendering context.

Parameters

premultipliedAlpha:Boolean

assembleAgal()method 
public static function assembleAgal(vertexShader:String, fragmentShader:String, resultProgram:Program3D = null):Program3D

Assembles fragment- and vertex-shaders, passed as Strings, to a Program3D. If you pass a 'resultProgram', it will be uploaded to that program; otherwise, a new program will be created on the current Stage3D context.

Parameters

vertexShader:String
 
fragmentShader:String
 
resultProgram:Program3D (default = null)

Returns
Program3D
batchQuad()method 
public function batchQuad(quad:Quad, parentAlpha:Number, texture:Texture = null, smoothing:String = null):void

Adds a quad to the current batch of unrendered quads. If there is a state change, all previous quads are rendered at once, and the batch is reset.

Parameters

quad:Quad
 
parentAlpha:Number
 
texture:Texture (default = null)
 
smoothing:String (default = null)

clear()method 
public function clear(rgb:uint = 0, alpha:Number = 0.0):void

Clears the render context with a certain color and alpha value.

Parameters

rgb:uint (default = 0)
 
alpha:Number (default = 0.0)

clear()method 
public static function clear(rgb:uint = 0, alpha:Number = 0.0):void

Clears the render context with a certain color and alpha value.

Parameters

rgb:uint (default = 0)
 
alpha:Number (default = 0.0)

configureBackBuffer()method 
public function configureBackBuffer(width:int, height:int, antiAlias:int, enableDepthAndStencil:Boolean):void

Configures the back buffer on the current context3D. By using this method, Starling can store the size of the back buffer and utilize this information in other methods (e.g. the scissor rectangle property). Back buffer width and height can later be accessed using the properties with the same name.

Parameters

width:int
 
height:int
 
antiAlias:int
 
enableDepthAndStencil:Boolean

dispose()method 
public function dispose():void

Disposes all quad batches.

finishQuadBatch()method 
public function finishQuadBatch():void

Renders the current quad batch and resets it.

loadIdentity()method 
public function loadIdentity():void

Changes the modelview matrix to the identity matrix.

nextFrame()method 
public function nextFrame():void

Resets matrix stack, blend mode, quad batch index, and draw count.

popMatrix()method 
public function popMatrix():void

Restores the modelview matrix that was last pushed to the stack.

prependMatrix()method 
public function prependMatrix(matrix:Matrix):void

Prepends a matrix to the modelview matrix by multiplying it another matrix.

Parameters

matrix:Matrix

pushMatrix()method 
public function pushMatrix():void

Pushes the current modelview matrix to a stack from which it can be restored later.

raiseDrawCount()method 
public function raiseDrawCount(value:uint = 1):void

Raises the draw count by a specific value. Call this method in custom render methods to keep the statistics display in sync.

Parameters

value:uint (default = 1)

resetMatrix()method 
public function resetMatrix():void

Empties the matrix stack, resets the modelview matrix to the identity matrix.

rotateMatrix()method 
public function rotateMatrix(angle:Number):void

Prepends a rotation (angle in radians) to the modelview matrix.

Parameters

angle:Number

scaleMatrix()method 
public function scaleMatrix(sx:Number, sy:Number):void

Prepends an incremental scale change to the modelview matrix.

Parameters

sx:Number
 
sy:Number

setBlendFactors()method 
public static function setBlendFactors(premultipliedAlpha:Boolean, blendMode:String = normal):void

Sets up the blending factors that correspond with a certain blend mode.

Parameters

premultipliedAlpha:Boolean
 
blendMode:String (default = normal)

setDefaultBlendFactors()method 
public static function setDefaultBlendFactors(premultipliedAlpha:Boolean):void

Deprecated. Call 'setBlendFactors' instead.

Parameters

premultipliedAlpha:Boolean

setOrthographicProjection()method 
public function setOrthographicProjection(x:Number, y:Number, width:Number, height:Number):void

Sets up the projection matrix for ortographic 2D rendering.

Parameters

x:Number
 
y:Number
 
width:Number
 
height:Number

transformMatrix()method 
public function transformMatrix(object:DisplayObject):void

Prepends translation, scale and rotation of an object to the modelview matrix.

Parameters

object:DisplayObject

transformMatrixForObject()method 
public static function transformMatrixForObject(matrix:Matrix, object:DisplayObject):void

Prepends translation, scale and rotation of an object to a custom matrix.

Parameters

matrix:Matrix
 
object:DisplayObject

translateMatrix()method 
public function translateMatrix(dx:Number, dy:Number):void

Prepends a translation to the modelview matrix.

Parameters

dx:Number
 
dy:Number