The RenderState stores a combination of settings that are currently used for rendering. This includes modelview and transformation matrices as well as context3D related settings.

Starling's Painter instance stores a reference to the current RenderState. Via a stack mechanism, you can always save a specific state and restore it later. That makes it easy to write rendering code that doesn't have any side effects.

Beware that any context-related settings are not applied on the context right away, but only after calling `painter.prepareToDraw()`. However, the Painter recognizes changes to those settings and will finish the current batch right away if necessary.

Matrix Magic

On rendering, Starling traverses the display tree, constantly moving from one coordinate system to the next. Each display object stores its vertex coordinates in its local coordinate system; on rendering, they must be moved to a global, 2D coordinate space (the so-called "clip-space"). To handle these calculations, the RenderState contains a set of matrices.

By multiplying vertex coordinates with the `modelviewMatrix`, you'll get the coordinates in "screen-space", or in other words: in stage coordinates. (Optionally, there's also a 3D version of this matrix. It comes into play when you're working with `Sprite3D` containers.)

By feeding the result of the previous transformation into the `projectionMatrix`, you'll end up with so-called "clipping coordinates", which are in the range `[-1, 1]` (just as needed by the graphics pipeline). If you've got vertices in the 3D space, this matrix will also execute a perspective projection.

Finally, there's the `mvpMatrix`, which is short for "modelviewProjectionMatrix". This is simply a combination of `modelview-` and `projectionMatrix`, combining the effects of both. Pass this matrix to the vertex shader and all your vertices will automatically end up at the right position.

@see Painter @see starling.display.Sprite3D

### Hierarchy

- RenderState

## Index

### Constructors

- constructor

### Properties

- alpha
- blendMode
- clipRect
- culling
- depthMask
- depthTest
- is3D
- modelviewMatrix
- modelviewMatrix3D
- mvpMatrix3D
- onDrawRequired
- projectionMatrix3D
- renderTarget
- renderTargetAntiAlias
- renderTargetBase
- renderTargetOptions
- renderTargetSupportsDepthAndStencil

### Methods

- copyFrom
- get_alpha
- get_blendMode
- get_clipRect
- get_culling
- get_depthMask
- get_depthTest
- get_is3D
- get_modelviewMatrix
- get_modelviewMatrix3D
- get_mvpMatrix3D
- get_onDrawRequired
- get_projectionMatrix3D
- get_renderTarget
- get_renderTargetAntiAlias
- get_renderTargetBase
- get_renderTargetOptions
- get_renderTargetSupportsDepthAndStencil
- reset
- setModelviewMatricesToIdentity
- setProjectionMatrix
- setProjectionMatrixChanged
- setRenderTarget
- set_alpha
- set_blendMode
- set_clipRect
- set_culling
- set_depthMask
- set_depthTest
- set_modelviewMatrix
- set_modelviewMatrix3D
- set_onDrawRequired
- set_projectionMatrix3D
- set_renderTarget
- transformModelviewMatrix
- transformModelviewMatrix3D

## Constructors

### constructor

- new RenderState(): RenderState

- - Defined in lib/starling/rendering/RenderState.d.ts:57

  Creates a new render state with the default settings.

  #### Returns RenderState

## Properties

### alpha

alpha: number

- Defined in lib/starling/rendering/RenderState.d.ts:154

The current, cumulated alpha value. Beware that, in a standard 'render' method, this already includes the current object! The value is the product of current object's alpha value and all its parents. @default 1.0

### blendMode

blendMode: string

- Defined in lib/starling/rendering/RenderState.d.ts:164

The blend mode to be used on rendering. A value of "auto" is ignored, since it means that the mode should remain unchanged.

@default BlendMode.NORMAL @see starling.display.BlendMode

### clipRect

clipRect: Rectangle

- Defined in lib/starling/rendering/RenderState.d.ts:211

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. To prevent any clipping, assign `null`.

@default null

### culling

culling: string

- Defined in lib/starling/rendering/RenderState.d.ts:187

Sets the triangle culling mode. Allows to exclude triangles from rendering based on their orientation relative to the view plane. @default Context3DTriangleFace.NONE

### depthMask

depthMask: boolean

- Defined in lib/starling/rendering/RenderState.d.ts:194

Enables or disables depth buffer writes. @default false

### depthTest

depthTest: string

- Defined in lib/starling/rendering/RenderState.d.ts:201

Sets type of comparison used for depth testing. @default Context3DCompareMode.ALWAYS

### is3D

is3D: boolean

- Defined in lib/starling/rendering/RenderState.d.ts:227

Indicates if there have been any 3D transformations. Returns `true` if the 3D modelview matrix contains a value.

### modelviewMatrix

modelviewMatrix: Matrix

- Defined in lib/starling/rendering/RenderState.d.ts:109

Returns the current 2D modelview matrix. CAUTION: Use with care! Each call returns the same instance. @default identity matrix

### modelviewMatrix3D

modelviewMatrix3D: Matrix3D

- Defined in lib/starling/rendering/RenderState.d.ts:116

Returns the current 3D modelview matrix, if there have been 3D transformations. CAUTION: Use with care! Each call returns the same instance. @default null

### mvpMatrix3D

mvpMatrix3D: Matrix3D

- Defined in lib/starling/rendering/RenderState.d.ts:131

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

### Private onDrawRequired

onDrawRequired: function

- Defined in lib/starling/rendering/RenderState.d.ts:235

#### Type declaration

- - (): void

  - #### Returns void

### projectionMatrix3D

projectionMatrix3D: Matrix3D

- Defined in lib/starling/rendering/RenderState.d.ts:125

Returns the current projection matrix. You can use the method 'setProjectionMatrix3D' to set it up in an intuitive way. CAUTION: Use with care! Each call returns the same instance. If you modify the matrix in place, you have to call `setProjectionMatrixChanged`. @default identity matrix

### renderTarget

renderTarget: Texture

- Defined in lib/starling/rendering/RenderState.d.ts:171

The texture that is currently being rendered into, or `null` to render into the back buffer. On assignment, calls `setRenderTarget` with its default parameters.

### renderTargetAntiAlias

renderTargetAntiAlias: number

- Defined in lib/starling/rendering/RenderState.d.ts:217

The anti-alias setting used when setting the current render target via `setRenderTarget`.

### Protected renderTargetBase

renderTargetBase: TextureBase

- Defined in lib/starling/rendering/RenderState.d.ts:176

### Protected renderTargetOptions

renderTargetOptions: number

- Defined in lib/starling/rendering/RenderState.d.ts:180

### renderTargetSupportsDepthAndStencil

renderTargetSupportsDepthAndStencil: boolean

- Defined in lib/starling/rendering/RenderState.d.ts:222

Indicates if the render target (set via `setRenderTarget`) has its depth and stencil buffers enabled.

## Methods

### copyFrom

- copyFrom(renderState: RenderState): void

- - Defined in lib/starling/rendering/RenderState.d.ts:62

  Duplicates all properties of another instance on the current instance.

  #### Parameters

  - ##### renderState: RenderState

  #### Returns void

### Protected get_alpha

- get_alpha(): number

- - Defined in lib/starling/rendering/RenderState.d.ts:155

  #### Returns number

### Protected get_blendMode

- get_blendMode(): string

- - Defined in lib/starling/rendering/RenderState.d.ts:165

  #### Returns string

### Protected get_clipRect

- get_clipRect(): Rectangle

- - Defined in lib/starling/rendering/RenderState.d.ts:212

  #### Returns Rectangle

### Protected get_culling

- get_culling(): string

- - Defined in lib/starling/rendering/RenderState.d.ts:188

  #### Returns string

### Protected get_depthMask

- get_depthMask(): boolean

- - Defined in lib/starling/rendering/RenderState.d.ts:195

  #### Returns boolean

### Protected get_depthTest

- get_depthTest(): string

- - Defined in lib/starling/rendering/RenderState.d.ts:202

  #### Returns string

### Protected get_is3D

- get_is3D(): boolean

- - Defined in lib/starling/rendering/RenderState.d.ts:228

  #### Returns boolean

### Protected get_modelviewMatrix

- get_modelviewMatrix(): Matrix

- - Defined in lib/starling/rendering/RenderState.d.ts:110

  #### Returns Matrix

### Protected get_modelviewMatrix3D

- get_modelviewMatrix3D(): Matrix3D

- - Defined in lib/starling/rendering/RenderState.d.ts:117

  #### Returns Matrix3D

### Protected get_mvpMatrix3D

- get_mvpMatrix3D(): Matrix3D

- - Defined in lib/starling/rendering/RenderState.d.ts:132

  #### Returns Matrix3D

### Protected get_onDrawRequired

- get_onDrawRequired(): function

- - Defined in lib/starling/rendering/RenderState.d.ts:236

  #### Returns function

  - - (): void

    - #### Returns void

### Protected get_projectionMatrix3D

- get_projectionMatrix3D(): Matrix3D

- - Defined in lib/starling/rendering/RenderState.d.ts:126

  #### Returns Matrix3D

### Protected get_renderTarget

- get_renderTarget(): Texture

- - Defined in lib/starling/rendering/RenderState.d.ts:172

  #### Returns Texture

### Protected get_renderTargetAntiAlias

- get_renderTargetAntiAlias(): number

- - Defined in lib/starling/rendering/RenderState.d.ts:218

  #### Returns number

### Protected get_renderTargetBase

- get_renderTargetBase(): TextureBase

- - Defined in lib/starling/rendering/RenderState.d.ts:177

  #### Returns TextureBase

### Protected get_renderTargetOptions

- get_renderTargetOptions(): number

- - Defined in lib/starling/rendering/RenderState.d.ts:181

  #### Returns number

### Protected get_renderTargetSupportsDepthAndStencil

- get_renderTargetSupportsDepthAndStencil(): boolean

- - Defined in lib/starling/rendering/RenderState.d.ts:223

  #### Returns boolean

### reset

- reset(): void

- - Defined in lib/starling/rendering/RenderState.d.ts:66

  Resets the RenderState to the default settings. (Check each property documentation for its default value.)

  #### Returns void

### setModelviewMatricesToIdentity

- setModelviewMatricesToIdentity(): void

- - Defined in lib/starling/rendering/RenderState.d.ts:104

  Changes the modelview matrices (2D and, if available, 3D) to identity matrices. An object transformed an identity matrix performs no transformation.

  #### Returns void

### setProjectionMatrix

- setProjectionMatrix(x: number, y: number, width: number, height: number, stageWidth?: number, stageHeight?: number, cameraPos?: Vector3D): void

- - Defined in lib/starling/rendering/RenderState.d.ts:92

  Creates a perspective projection matrix suitable for 2D and 3D rendering.

  The first 4 parameters define which area of the stage you want to view (the camera will 'zoom' to exactly this region). The final 3 parameters determine the perspective in which you're looking at the stage.

  The stage is always on the rectangle that is spawned up between x- and y-axis (with the given size). All objects that are exactly on that rectangle (z equals zero) will be rendered in their true size, without any distortion.

  If you pass only the first 4 parameters, the camera will be set up above the center of the stage, with a field of view of 1.0 rad.

  #### Parameters

  - ##### x: number

  - ##### y: number

  - ##### width: number

  - ##### height: number

  - ##### Optional stageWidth: number

  - ##### Optional stageHeight: number

  - ##### Optional cameraPos: Vector3D

  #### Returns void

### setProjectionMatrixChanged

- setProjectionMatrixChanged(): void

- - Defined in lib/starling/rendering/RenderState.d.ts:99

  This method needs to be called whenever `projectionMatrix3D` was changed other than via `setProjectionMatrix`.

  #### Returns void

### setRenderTarget

- setRenderTarget(target: Texture, enableDepthAndStencil?: boolean, antiAlias?: number): void

- - Defined in lib/starling/rendering/RenderState.d.ts:145

  Changes the the current render target.

  @param target Either a texture or `null` to render into the back buffer. @param enableDepthAndStencil Indicates if depth and stencil testing will be available. This parameter affects only texture targets. @param antiAlias The anti-aliasing quality (range: `0 - 4`). This parameter affects only texture targets. Note that at the time of this writing, AIR supports anti-aliasing only on Desktop.

  #### Parameters

  - ##### target: Texture

  - ##### Optional enableDepthAndStencil: boolean

  - ##### Optional antiAlias: number

  #### Returns void

### Protected set_alpha

- set_alpha(value: number): number

- - Defined in lib/starling/rendering/RenderState.d.ts:156

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_blendMode

- set_blendMode(value: string): string

- - Defined in lib/starling/rendering/RenderState.d.ts:166

  #### Parameters

  - ##### value: string

  #### Returns string

### Protected set_clipRect

- set_clipRect(value: Rectangle): Rectangle

- - Defined in lib/starling/rendering/RenderState.d.ts:213

  #### Parameters

  - ##### value: Rectangle

  #### Returns Rectangle

### Protected set_culling

- set_culling(value: string): string

- - Defined in lib/starling/rendering/RenderState.d.ts:189

  #### Parameters

  - ##### value: string

  #### Returns string

### Protected set_depthMask

- set_depthMask(value: boolean): boolean

- - Defined in lib/starling/rendering/RenderState.d.ts:196

  #### Parameters

  - ##### value: boolean

  #### Returns boolean

### Protected set_depthTest

- set_depthTest(value: string): string

- - Defined in lib/starling/rendering/RenderState.d.ts:203

  #### Parameters

  - ##### value: string

  #### Returns string

### Protected set_modelviewMatrix

- set_modelviewMatrix(value: Matrix): Matrix

- - Defined in lib/starling/rendering/RenderState.d.ts:111

  #### Parameters

  - ##### value: Matrix

  #### Returns Matrix

### Protected set_modelviewMatrix3D

- set_modelviewMatrix3D(value: Matrix3D): Matrix3D

- - Defined in lib/starling/rendering/RenderState.d.ts:118

  #### Parameters

  - ##### value: Matrix3D

  #### Returns Matrix3D

### Protected set_onDrawRequired

- set_onDrawRequired(value: function): function

- - Defined in lib/starling/rendering/RenderState.d.ts:237

  #### Parameters

  - ##### value: function

    - - (): void

      - #### Returns void

  #### Returns function

  - - (): void

    - #### Returns void

### Protected set_projectionMatrix3D

- set_projectionMatrix3D(value: Matrix3D): Matrix3D

- - Defined in lib/starling/rendering/RenderState.d.ts:127

  #### Parameters

  - ##### value: Matrix3D

  #### Returns Matrix3D

### Protected set_renderTarget

- set_renderTarget(value: Texture): Texture

- - Defined in lib/starling/rendering/RenderState.d.ts:173

  #### Parameters

  - ##### value: Texture

  #### Returns Texture

### transformModelviewMatrix

- transformModelviewMatrix(matrix: Matrix): void

- - Defined in lib/starling/rendering/RenderState.d.ts:71

  Prepends the given matrix to the 2D modelview matrix.

  #### Parameters

  - ##### matrix: Matrix

  #### Returns void

### transformModelviewMatrix3D

- transformModelviewMatrix3D(matrix: Matrix3D): void

- - Defined in lib/starling/rendering/RenderState.d.ts:77

  Prepends the given matrix to the 3D modelview matrix. The current contents of the 2D modelview matrix is stored in the 3D modelview matrix before doing so; the 2D modelview matrix is then reset to the identity matrix.

  #### Parameters

  - ##### matrix: Matrix3D

  #### Returns void

Generated using TypeDoc