GODPAPER | All Packages | All Classes | Index | Frames No Frames |
RenderSupport

Package | starling.core
Class | public class RenderSupport
Inheritance | RenderSupport 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

| Property | Defined By
--- | --- | ---
|  | 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 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

Public Methods

| Method | Defined By
--- | --- | ---
|  | RenderSupport() 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
|  | applyClipRect():void Updates the context3D scissor rectangle using the current clipping rectangle. | 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
|  | batchQuadBatch(quadBatch:QuadBatch, parentAlpha:Number):void Adds a batch of quads 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
|  | dispose():void Disposes all quad batches. | RenderSupport
|  | finishQuadBatch():void Renders the current quad batch and resets it. | RenderSupport
|  | getTextureLookupFlags(format:String, mipMapping:Boolean, repeat:Boolean = false, smoothing:String = bilinear):String [static] Returns the flags that are required for AGAL texture lookup, including the '<' and '>' delimiters. | RenderSupport
|  | loadIdentity():void Changes the modelview matrix to the identity matrix. | RenderSupport
|  | nextFrame():void Resets matrix stack, blend mode, quad batch index, and draw count. | RenderSupport
|  | popClipRect():void Restores the clipping rectangle that was last pushed to the stack. | 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 with another matrix. | RenderSupport
|  | pushClipRect(rectangle:Rectangle):Rectangle The clipping rectangle can be used to limit rendering in the current render target to a certain area. | 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
|  | resetMatrix():void 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
|  | transformMatrix(object:DisplayObject):void 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

blendMode | property

`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`

drawCount | property |

`drawCount:int` [read-only]

Indicates the number of stage3D draw calls.

Implementation
`public function get drawCount():int`

modelViewMatrix | property |

`modelViewMatrix:Matrix` [read-only]

Returns the current modelview matrix. CAUTION: Use with care! Each call returns the same instance.

Implementation
`public function get modelViewMatrix():Matrix`

mvpMatrix | property |

`mvpMatrix:Matrix` [read-only]

Calculates the product of modelview and projection matrix. CAUTION: Use with care! Each call returns the same instance.

Implementation
`public function get mvpMatrix():Matrix`

mvpMatrix3D | property |

`mvpMatrix3D:Matrix3D` [read-only]

Calculates the product of modelview and projection matrix and saves it in a 3D matrix. CAUTION: Use with care! Each call returns the same instance.

Implementation
`public function get mvpMatrix3D():Matrix3D`

projectionMatrix | property |

`projectionMatrix:Matrix`

Returns the current projection matrix. CAUTION: Use with care! Each call returns the same instance.

Implementation
`public function get projectionMatrix():Matrix`
`public function set projectionMatrix(value:Matrix):void`

renderTarget | property |

`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`
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`

applyClipRect | () | method |

`public function applyClipRect():void`

Updates the context3D scissor rectangle using the current clipping rectangle. This method is called automatically when either the render target, the projection matrix, or the clipping rectangle changes.

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`)``

batchQuadBatch | () | method |

`public function batchQuadBatch(quadBatch:QuadBatch, parentAlpha:Number):void`

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

Note that you should call this method only for objects with a small number of quads (we recommend no more than 16). Otherwise, the additional CPU effort will be more expensive than what you save by avoiding the draw call.

Parameters

| `quadBatch:QuadBatch`
| `parentAlpha:Number`

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`)``

dispose | () | method |

`public function dispose():void`

Disposes all quad batches.

finishQuadBatch | () | method |

`public function finishQuadBatch():void`

Renders the current quad batch and resets it.

getTextureLookupFlags | () | method |

`public static function getTextureLookupFlags(format:String, mipMapping:Boolean, repeat:Boolean = false, smoothing:String = bilinear):String`

Returns the flags that are required for AGAL texture lookup, including the '<' and '>' delimiters.

Parameters

| `format:String`
| `mipMapping:Boolean`
| `repeat:Boolean` (default = `false`)``
| `smoothing:String` (default = `bilinear`)``

Returns

| `String`

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.

popClipRect | () | method |

`public function popClipRect():void`

Restores the clipping rectangle that was last pushed to the stack.

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 with another matrix.

Parameters

| `matrix:Matrix`

pushClipRect | () | method |

`public function pushClipRect(rectangle:Rectangle):Rectangle`

The clipping rectangle can be used to limit rendering in the current render target to a certain area. This method expects the rectangle in stage coordinates. Internally, it uses the 'scissorRectangle' of stage3D, which works with pixel coordinates. Any pushed rectangle is intersected with the previous rectangle; the method returns that intersection.

Parameters

| `rectangle:Rectangle`

Returns

| `Rectangle`

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`

Thu Jan 16 2014, 01:11 PM +08:00