RenderContext
Namespace: Murder.Core.Graphics
Assembly: Murder.dll
public class RenderContext : IDisposable
Implements: IDisposable
⭐ Constructors
public RenderContext(GraphicsDevice graphicsDevice, Camera2D camera, RenderContextFlags settings)
A context for how to render your game. Holds everything you need to draw on the screen. To make your own, extend this class and add it to [Game.CreateRenderContext(Microsoft.Xna.Framework.Graphics.GraphicsDevice,Murder.Core.Graphics.Camera2D,Murder.Core.Graphics.RenderContextFlags)](../../../Murder/Game.html#createrendercontext(graphicsdevice,) Extending your Batches2D file is also recommended.
Parameters
graphicsDevice
GraphicsDevice
camera
Camera2D
settings
RenderContextFlags
⭐ Properties
_debugTarget
protected RenderTarget2D _debugTarget;
Returns
RenderTarget2D
_debugTargetPreview
protected RenderTarget2D _debugTargetPreview;
Returns
RenderTarget2D
_finalTarget
protected RenderTarget2D _finalTarget;
The final screen target, has the real screen size.
Returns
RenderTarget2D
_floorBufferTarget
protected RenderTarget2D _floorBufferTarget;
Returns
RenderTarget2D
_graphicsDevice
protected GraphicsDevice _graphicsDevice;
Returns
GraphicsDevice
_mainTarget
protected RenderTarget2D _mainTarget;
Returns
RenderTarget2D
_spriteBatches
public Batch2D[] _spriteBatches;
Returns
Batch2D[]
_subPixelOffset
protected Vector2 _subPixelOffset;
Returns
Vector2
_tempTarget
protected RenderTarget2D _tempTarget;
Temporary buffer with the camera size. Used so we can apply effects such as limited palette and bloom on a smaller screen before applying it to the final target
Returns
RenderTarget2D
_uiTarget
protected RenderTarget2D _uiTarget;
Returns
RenderTarget2D
_useDebugBatches
protected readonly bool _useDebugBatches;
Returns
bool
BackColor
public Color BackColor { get; }
Returns
Color
CachedTextTextures
public readonly CacheDictionary<TKey, TValue> CachedTextTextures;
Returns
CacheDictionary<TKey, TValue>
Camera
public readonly Camera2D Camera;
The active camera used for rendering scenes.
Returns
Camera2D
CAMERA_BLEED
public readonly static int CAMERA_BLEED;
Returns
int
CAMERA_BLEED_VECTOR
public readonly static Vector2 CAMERA_BLEED_VECTOR;
Returns
Vector2
ColorGrade
public Texture2D ColorGrade;
Returns
Texture2D
DebugBatch
public Batch2D DebugBatch { get; }
Only used if RenderContextFlags.Debug is set. Influenced by the camera.
Returns
Batch2D
DebugFxBatch
public Batch2D DebugFxBatch { get; }
Only used if RenderContextFlags.Debug is set, has a nice effect to it. Influenced by the camera.
Returns
Batch2D
FloorBatch
public Batch2D FloorBatch { get; }
Renders behind the RenderContext.GameplayBatch, influenced by the camera.
Returns
Batch2D
GameBufferSize
public Point GameBufferSize;
Returns
Point
GameplayBatch
public Batch2D GameplayBatch { get; }
Intended to be the main gameplay batch, influenced by the camera.
Returns
Batch2D
GameUiBatch
public Batch2D GameUiBatch { get; }
Renders in front of the RenderContext.GameplayBatch, influenced by the camera.
Returns
Batch2D
LastRenderTarget
public RenderTarget2D LastRenderTarget { get; }
Returns
RenderTarget2D
MainTarget
public RenderTarget2D MainTarget { get; }
Returns
RenderTarget2D
PreviewState
public BatchPreviewState PreviewState;
Returns
BatchPreviewState
PreviewStretch
public bool PreviewStretch;
Returns
bool
RenderToScreen
public bool RenderToScreen;
Returns
bool
Settings
protected readonly RenderContextFlags Settings;
Returns
RenderContextFlags
SubPixelOffset
public Vector2 SubPixelOffset { get; }
Returns
Vector2
UiBatch
public Batch2D UiBatch { get; }
Renders above everything, ignores any camera movement.
Returns
Batch2D
Viewport
public Viewport Viewport;
Returns
Viewport
⭐ Methods
SetupRenderTarget(RenderTarget2D, int, int, Color, bool)
protected RenderTarget2D SetupRenderTarget(RenderTarget2D existingTarget, int width, int height, Color clearColor, bool preserveContents)
Sets up a new RenderTarget2D, disposing of the existing one if necessary.
Parameters
existingTarget
RenderTarget2D
width
int
height
int
clearColor
Color
preserveContents
bool
Returns
RenderTarget2D
AfterMainRender(RenderTarget2D)
protected virtual void AfterMainRender(RenderTarget2D mainTarget)
Called right after RenderContext.GameUiBatch end.
Parameters
mainTarget
RenderTarget2D
AfterUiRender(RenderTarget2D)
protected virtual void AfterUiRender(RenderTarget2D uiTarget)
Called right after the RenderContext.UiBatch ends.
Parameters
uiTarget
RenderTarget2D
BeforeScreenRender(RenderTarget2D)
protected virtual void BeforeScreenRender(RenderTarget2D finalTarget)
Last chance to render anything before the contents are drawn on the screen!
Parameters
finalTarget
RenderTarget2D
UnloadImpl()
protected virtual void UnloadImpl()
Override for custom unload implementations in derived classes.
RegisterSpriteBatch(int, Batch2D)
protected void RegisterSpriteBatch(int index, Batch2D batch)
Registers a SpriteBatch at a specified index. If the index is already taken, it will be overwritten.
Parameters
index
int
batch
Batch2D
TakeScreenshotIfNecessary(RenderTarget2D)
protected void TakeScreenshotIfNecessary(RenderTarget2D target)
Parameters
target
RenderTarget2D
GetBatch(int)
public Batch2D GetBatch(int index)
Parameters
index
int
Returns
Batch2D
RefreshWindow(GraphicsDevice, Point, Point, ViewportResizeStyle)
public bool RefreshWindow(GraphicsDevice graphicsDevice, Point viewportSize, Point nativeResolution, ViewportResizeStyle viewportResizeMode)
Refreshes the window with the new viewport size and camera scale.
Parameters
graphicsDevice
GraphicsDevice
viewportSize
Point
nativeResolution
Point
viewportResizeMode
ViewportResizeStyle
Returns
bool
GetRenderTargetFromEnum(RenderTargets)
public virtual Texture2D GetRenderTargetFromEnum(RenderTargets inspectingRenderTarget)
Parameters
inspectingRenderTarget
RenderTargets
Returns
Texture2D
Begin()
public virtual void Begin()
Dispose()
public virtual void Dispose()
Disposes of all associated resources.
End()
public virtual void End()
Initialize()
public virtual void Initialize()
UpdateViewport()
public virtual void UpdateViewport()
CreateDebugPreviewIfNecessary(BatchPreviewState, RenderTarget2D)
public void CreateDebugPreviewIfNecessary(BatchPreviewState currentState, RenderTarget2D target)
Parameters
currentState
BatchPreviewState
target
RenderTarget2D
SaveScreenShot(Rectangle)
public void SaveScreenShot(Rectangle cameraRect)
Saves a screenshot of the specified camera area.
Parameters
cameraRect
Rectangle
Unload()
public void Unload()
Unload the render context. Called when the render context is no longer being actively displayed.
⚡