SpriteBatch.Begin Method (SpriteBlendMode, SpriteSortMode, SaveStateMode, Matrix)
Prepares the graphics device for drawing sprites with specified blending, sorting, and render state options.
Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)
Syntax
public void Begin (
SpriteBlendMode blendMode,
SpriteSortMode sortMode,
SaveStateMode stateMode,
Matrix transformMatrix
)
Parameters
- blendMode
Blending options to use when rendering. - sortMode
Sorting options to use when rendering. - stateMode
Rendering state options. - transformMatrix
A matrix to apply to position, rotation, scale, and depth data passed to Draw.
Remarks
This method must be called before any calls to Draw. When all the sprites have been drawn, call End.
Begin sets the following render states:
- CullMode
- DepthBufferEnable
- AlphaBlendEnable
- AlphaTestEnable
- AlphaBlendOperation
- SourceBlend
- DestinationBlend
- SeparateAlphaBlendEnabled
- AlphaFunction
- ReferenceAlpha
Begin sets the following sampler states:
If Begin is called with SaveStateMode set to None, then these states must be reset by the caller if they are used elsewhere. Calling Begin with SaveStateMode set to SaveState will reset these values properly, but may adversely affect performance.
Use transformMatrix to apply the same transformation to all sprites drawn by this SpriteBatch. This matrix can be any combination of translation, scaling, or rotation operations. This matrix is applied to the position, rotation, scale, and depth values provided to Draw.
See Also
Tasks
Concepts
Reference
SpriteBatch Class
SpriteBatch Members
Microsoft.Xna.Framework.Graphics Namespace
Platforms
Xbox 360, Windows XP SP2, Windows Vista