Skip to content

708C59E8

Marcel Härtel edited this page Aug 27, 2023 · 2 revisions

BeginRenderTarget Method

Everything between BeginRenderTarget() and EndRenderTarget() will be drawn to the RenderTarget2D.

Definition

Namespace: MonoGame.Forms.NET.Services
Assembly: MonoGame.Forms.NET (in MonoGame.Forms.NET.dll) Version: 3.2.0

C#

public void BeginRenderTarget(
	string key,
	bool clearGraphics = true,
	Color? clearColor = null,
	ClearOptions clearOptions = ClearOptions.Target|ClearOptions.DepthBuffer|ClearOptions.Stencil,
	float depth = 1f,
	int stencil = 0
)

Parameters

  String
Please enter a previously set key of the RenderTarget2D you want to begin with.
  Boolean  (Optional)
false if you don't want to to call GraphicsDevice.Clear() after setting the RenderTarget2D.
  Nullable(Color)  (Optional)
The Color to be used to clear the GraphicsDevice after setting the RenderTarget2D.
  ClearOptions  (Optional)
Define your custom ClearOptions.
  Single  (Optional)
The depth.
  Int32  (Optional)
The stencil

Example

C#

protected override void Draw()
{
   base.Draw();

   Editor.BeginRenderTarget("MyRenderTarget");

   Editor.spriteBatch.Begin();

   //Your drawings

   Editor.spriteBatch.End();

   Editor.EndRenderTarget("MyRenderTarget", false);
}

See Also

Reference

EditorService Class
MonoGame.Forms.NET.Services Namespace

Clone this wiki locally