RenderPipelineRenderContext

Warning

This documentation is for an implementation of a service. This class is not meant to be used directly; instead use the IRenderContext service via dependency injection to access this functionality.

Information documented here may not be up to date.

class RenderPipelineRenderContext : System.Object, IRenderContext

The implementation of T:Protogame.IRenderContext which provides additional APIs for interacting with the render pipeline.

readonly BoundingFrustum BoundingFrustum

Gets the bounding frustum for the current view and projection matrixes.

Value:The bounding frustum for the current view and projection matrixes.
readonly GraphicsDevice GraphicsDevice

Gets the associated graphics device.

Value:The graphics device.
bool Is3DContext

Gets or sets a value indicating whether the world manager is currently rendering a 3D context. For games using a 2D world manager, this will always be false. For 3D games, world managers will do an initial 3D pass followed by a 2D pass that is rendered on top (for UI, etc.) In a 3D context, only I3DRenderUtilities can be used; in a 2D context, only I2DRenderUtilities can be used.

Value:Whether the rendering context is currently a 3D context.
bool IsRendering

Gets a value indicating whether the game is currently rendering in either the render pipeline or the backbuffer. This value will always be true within any method call that occurs below M:Microsoft.Xna.Framework.Game.Draw(Microsoft.Xna.Framework.GameTime) in the call stack. When you are rendering, certain operations can not be performed, in particular, operations which reset the graphics device like resizing the game window.

Vector3 CameraPosition

Gets or sets the last known camera position. The value of this property is set internally by cameras so that the camera position is known when lighting effects are applied. Setting this property from user code will not actually update the camera position or modify projection parameters; it will only impact the way lights are rendered.

Vector3 CameraLookAt

Gets or sets the last known camera look at vector. The value of this property is set internally by cameras so that the camera look at vector is known when lighting effects are applied. Setting this property from user code will not actually update the camera look at vector or modify projection parameters; it will only impact the way lights are rendered.

Matrix Projection

Gets or sets the projection matrix for 3D rendering.

Value:The projection matrix for 3D rendering.
readonly Texture2D SingleWhitePixel

Gets a texture representing a single white pixel.

Value:The single white pixel.
readonly SpriteBatch SpriteBatch

Gets a sprite batch associated with the current device, upon which 2D rendering is performed.

Value:The sprite batch.
Matrix View

Gets or sets the view matrix for 3D rendering.

Value:The view matrix for 3D rendering.
Matrix World

Gets or sets the world matrix for 3D rendering.

Value:The world matrix for 3D rendering.
readonly IRenderPass CurrentRenderPass

Gets the current render pass that is being used.

Value:The current render pass that is being used.
public void PopRenderTarget()

Pops the current render target from the current rendering context. If there are no more render targets in the stack after this call, then the rendering will default back to rendering to the back buffer.

public void PushRenderTarget(RenderTargetBinding renderTarget)

Push a render target onto the current rendering context, making it the active target for rendering. By using the PushRenderTarget / PopRenderTarget methods, this allows you to safely chain render target switches, without risk of losing the previous render target. An example of where this can be used is if you want to capture the next frame, you can simply start with a PushRenderTarget and as long as all other render target switching uses these methods or respects the previous render target, then everything will be captured as intended.

Parameters:
  • renderTarget (Microsoft.Xna.Framework.Graphics.RenderTargetBinding) – The render target instance to make active.
public void PushRenderTarget(Microsoft.Xna.Framework.Graphics.RenderTargetBinding[] renderTargets)

Push an array of render targets onto the current rendering context, making them the active target for rendering. By using the PushRenderTarget / PopRenderTarget methods, this allows you to safely chain render target switches, without risk of losing the previous render target.

Parameters:
  • renderTargets (Microsoft.Xna.Framework.Graphics.RenderTargetBinding[]) – The render targets to make active.
public void Render(IGameContext context)

The render.

Parameters:
  • context (Protogame.IGameContext) – The context.
public void PostPreRender(IGameContext context)
Parameters:
  • context (Protogame.IGameContext) –
public IRenderPass AddFixedRenderPass(IRenderPass renderPass)

Adds the specified render pass to the render pipeline permanently. This render pass will take effect after the start of the next frame.

Parameters:
  • renderPass (Protogame.IRenderPass) – The render pass to add.
Returns:

The render pass that was given to this function. This return value is for convenience only, so that you may construct and add a render pass in a single statement, while obtaining a reference to it if you need to modify it’s values or call M:Protogame.RenderPipelineRenderContext.RemoveFixedRenderPass(Protogame.IRenderPass) later. The render pass is not modified by this function.

public void RemoveFixedRenderPass(IRenderPass renderPass)

Removes the specified render pass from the render pipeline.

Parameters:
  • renderPass (Protogame.IRenderPass) – The render pass to remove.
public IRenderPass AppendTransientRenderPass(IRenderPass renderPass)

Append the specified render pass to the render pipeline for this frame only. This is method that allows you to temporarily add additional render passes to a frame.

If all standard (non-post-processing) render passes have finished post-processing has begun and this method is given a standard render pass, it will have no effect.

Render passes that were appended can not be removed with M:Protogame.RenderPipelineRenderContext.RemoveFixedRenderPass(Protogame.IRenderPass).

Parameters:
  • renderPass (Protogame.IRenderPass) – The render pass to add.
Returns:

The render pass that was given to this function. This return value is for convenience only, so that you may construct and add a render pass in a single statement, while obtaining a reference to it if you need to modify it’s value. The render pass is not modified by this function.

public bool IsCurrentRenderPass<T>()

Returns whether or not the current render pass is of the specified type.

Type Parameters:
 
  • T – The type to check the render pass against.
Returns:

Whether or not the current render pass is of the specified type.

public bool IsCurrentRenderPass<T>(ref Protogame.T currentRenderPass)
Type Parameters:
 
  • T
Parameters:
  • (ref) currentRenderPass (Protogame.T) –
public Protogame.T GetCurrentRenderPass<T>()

Returns the current render pass as the type T.

Type Parameters:
 
  • T – The type of render pass to return.
Returns:

The current render pass as the type T.

public bool IsFirstRenderPass()

Returns whether this is the first render pass being performed. You can use this method to isolate render logic that should only occur once per frame (such as appending transient render passes).

Returns:Whether this is the first render pass being performed.