C# Class Sparrow.Core.RenderSupport

Mostrar archivo Open project: fmotagarcia/sparrow-sharp Class Usage Examples

Public Methods

Method Description
AddDrawCalls ( int count ) : void

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

ApplyBlendMode ( bool premultipliedAlpha ) : void

Activates the current blend mode.

BatchQuad ( Quad quad ) : void

Adds a quad or image 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. Note that the values for alpha and blend mode are taken from the current render state, not the quad.

CheckForOpenGLError ( ) : uint

Checks for an OpenGL error. If there is one, it is logged an the error code is returned.

Clear ( uint color, float alpha = 0.0f ) : void

Clears OpenGL's color buffer with a specified color.

FinishQuadBatch ( ) : void

Renders the current quad batch and resets it.

NextFrame ( ) : void

Resets the render state stack to the default.

PopClipRect ( ) : void

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

PopState ( ) : void

Restores the previous render state.

PurgeBuffers ( ) : void

Clears all vertex and index buffers, releasing the associated memory. Useful in low-memory situations. Don't call from within a render method!

PushClipRect ( Rectangle clipRect ) : 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 'glScissor' command of OpenGL, which works with pixel coordinates. Any pushed rectangle is intersected with the previous rectangle; the method returns that intersection.

PushState ( Matrix matrix, float alpha, uint blendMode ) : void

Adds a new render state to the stack. The passed matrix is prepended to the modelview matrix; the alpha value is multiplied with the current alpha; the blend mode replaces the existing mode (except 'BlendMode.Auto', which will cause the current mode to prevail).

RenderSupport ( ) : System
SetupOrthographicProjection ( float left, float right, float top, float bottom ) : void

Sets up the projection matrix for ortographic 2D rendering.

Private Methods

Method Description
ApplyClipRect ( ) : void

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

Method Details

AddDrawCalls() public method

Raises the number of draw calls by a specific value. Call this method in custom render methods to keep the statistics display in sync.
public AddDrawCalls ( int count ) : void
count int
return void

ApplyBlendMode() public method

Activates the current blend mode.
public ApplyBlendMode ( bool premultipliedAlpha ) : void
premultipliedAlpha bool
return void

BatchQuad() public method

Adds a quad or image 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. Note that the values for alpha and blend mode are taken from the current render state, not the quad.
public BatchQuad ( Quad quad ) : void
quad Quad
return void

CheckForOpenGLError() public static method

Checks for an OpenGL error. If there is one, it is logged an the error code is returned.
public static CheckForOpenGLError ( ) : uint
return uint

Clear() public method

Clears OpenGL's color buffer with a specified color.
public Clear ( uint color, float alpha = 0.0f ) : void
color uint
alpha float
return void

FinishQuadBatch() public method

Renders the current quad batch and resets it.
public FinishQuadBatch ( ) : void
return void

NextFrame() public method

Resets the render state stack to the default.
public NextFrame ( ) : void
return void

PopClipRect() public method

Restores the clipping rectangle that was last pushed to the stack.
public PopClipRect ( ) : void
return void

PopState() public method

Restores the previous render state.
public PopState ( ) : void
return void

PurgeBuffers() public method

Clears all vertex and index buffers, releasing the associated memory. Useful in low-memory situations. Don't call from within a render method!
public PurgeBuffers ( ) : void
return void

PushClipRect() public method

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 'glScissor' command of OpenGL, which works with pixel coordinates. Any pushed rectangle is intersected with the previous rectangle; the method returns that intersection.
public PushClipRect ( Rectangle clipRect ) : Rectangle
clipRect Sparrow.Geom.Rectangle
return Sparrow.Geom.Rectangle

PushState() public method

Adds a new render state to the stack. The passed matrix is prepended to the modelview matrix; the alpha value is multiplied with the current alpha; the blend mode replaces the existing mode (except 'BlendMode.Auto', which will cause the current mode to prevail).
public PushState ( Matrix matrix, float alpha, uint blendMode ) : void
matrix Matrix
alpha float
blendMode uint
return void

RenderSupport() public method

public RenderSupport ( ) : System
return System

SetupOrthographicProjection() public method

Sets up the projection matrix for ortographic 2D rendering.
public SetupOrthographicProjection ( float left, float right, float top, float bottom ) : void
left float
right float
top float
bottom float
return void