Class BatchBase<TDrawInfo>
Base class to batch a group of draw calls into one.
public abstract class BatchBase<TDrawInfo> : ComponentBase, IDisposable, IComponent, IReferencable, ICollectorHolder where TDrawInfo : struct
Type Parameters
TDrawInfo
A structure containing all the required information to draw one element of the batch.
- Inheritance
-
BatchBase<TDrawInfo>
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
BatchBase(GraphicsDevice, EffectBytecode, EffectBytecode, ResourceBufferInfo, VertexDeclaration, int)
protected BatchBase(GraphicsDevice device, EffectBytecode defaultEffectByteCode, EffectBytecode defaultEffectByteCodeSRgb, BatchBase<TDrawInfo>.ResourceBufferInfo resourceBufferInfo, VertexDeclaration vertexDeclaration, int indexSize = 2)
Parameters
device
GraphicsDevicedefaultEffectByteCode
EffectBytecodedefaultEffectByteCodeSRgb
EffectBytecoderesourceBufferInfo
BatchBase<TDrawInfo>.ResourceBufferInfovertexDeclaration
VertexDeclarationindexSize
int
Fields
DefaultEffect
protected readonly EffectInstance DefaultEffect
Field Value
DefaultEffectSRgb
protected readonly EffectInstance DefaultEffectSRgb
Field Value
ResourceContext
protected BatchBase<TDrawInfo>.DeviceResourceContext ResourceContext
Field Value
- BatchBase<TDrawInfo>.DeviceResourceContext
ResourceContextPool
protected readonly ThreadLocal<BatchBase<TDrawInfo>.DeviceResourceContext> ResourceContextPool
Field Value
- ThreadLocal<BatchBase<TDrawInfo>.DeviceResourceContext>
blendState
protected BlendStateDescription? blendState
Field Value
depthStencilState
protected DepthStencilStateDescription? depthStencilState
Field Value
graphicsDevice
protected GraphicsDevice graphicsDevice
Field Value
mutablePipeline
protected MutablePipelineState mutablePipeline
Field Value
rasterizerState
protected RasterizerStateDescription? rasterizerState
Field Value
samplerState
protected SamplerState samplerState
Field Value
sortMode
protected SpriteSortMode sortMode
Field Value
stencilReferenceValue
protected int stencilReferenceValue
Field Value
Properties
BackToFrontComparer
protected BatchBase<TDrawInfo>.QueueComparer<BatchBase<TDrawInfo>.ElementInfo> BackToFrontComparer { get; set; }
Property Value
- BatchBase<TDrawInfo>.QueueComparer<BatchBase<TDrawInfo>.ElementInfo>
Effect
The effect used for the current Begin/End session.
protected EffectInstance Effect { get; }
Property Value
FrontToBackComparer
protected BatchBase<TDrawInfo>.QueueComparer<BatchBase<TDrawInfo>.ElementInfo> FrontToBackComparer { get; set; }
Property Value
- BatchBase<TDrawInfo>.QueueComparer<BatchBase<TDrawInfo>.ElementInfo>
GraphicsContext
protected GraphicsContext GraphicsContext { get; }
Property Value
Parameters
Gets the parameters applied on the SpriteBatch effect.
public ParameterCollection Parameters { get; }
Property Value
- ParameterCollection
The parameters.
TextureComparer
protected BatchBase<TDrawInfo>.TextureIdComparer TextureComparer { get; set; }
Property Value
- BatchBase<TDrawInfo>.TextureIdComparer
Methods
Begin(GraphicsContext, EffectInstance, SpriteSortMode, BlendStateDescription?, SamplerState, DepthStencilStateDescription?, RasterizerStateDescription?, int)
Begins a sprite batch rendering using the specified sorting mode and blend state, sampler, depth stencil, rasterizer state objects and a custom effect. Passing null for any of the state objects selects the default default state objects (BlendState.AlphaBlend, depthStencilState.None, RasterizerState.CullCounterClockwise, SamplerState.LinearClamp). Passing a null effect selects the default effect shader.
protected void Begin(GraphicsContext graphicsContext, EffectInstance effect, SpriteSortMode sessionSortMode, BlendStateDescription? sessionBlendState, SamplerState sessionSamplerState, DepthStencilStateDescription? sessionDepthStencilState, RasterizerStateDescription? sessionRasterizerState, int stencilValue)
Parameters
graphicsContext
GraphicsContextThe graphics context to use.
effect
EffectInstanceThe effect to use for this begin/end draw session (default effect if null)
sessionSortMode
SpriteSortModeSprite drawing order used for the Begin/End session.
sessionBlendState
BlendStateDescription?Blending state used for the Begin/End session
sessionSamplerState
SamplerStateTexture sampling used for the Begin/End session
sessionDepthStencilState
DepthStencilStateDescription?Depth and stencil state used for the Begin/End session
sessionRasterizerState
RasterizerStateDescription?Rasterization state used for the Begin/End session
stencilValue
intThe value of the stencil buffer to take as reference for the Begin/End session
Exceptions
- InvalidOperationException
Only one SpriteBatch at a time can use SpriteSortMode.Immediate
CheckBeginHasBeenCalled(string)
protected void CheckBeginHasBeenCalled(string functionName)
Parameters
functionName
string
CheckEndHasBeenCalled(string)
protected void CheckEndHasBeenCalled(string functionName)
Parameters
functionName
string
Destroy()
Disposes of object resources.
protected override void Destroy()
Draw(Texture, in ElementInfo)
protected void Draw(Texture texture, in BatchBase<TDrawInfo>.ElementInfo elementInfo)
Parameters
texture
TextureelementInfo
BatchBase<TDrawInfo>.ElementInfo
End()
Flushes the sprite batch and restores the device state to how it was before Begin was called.
public void End()
PrepareForRendering()
protected virtual void PrepareForRendering()
UpdateBufferValuesFromElementInfo(ref ElementInfo, IntPtr, IntPtr, int)
Update the mapped vertex and index buffer values using the provided element info.
protected abstract void UpdateBufferValuesFromElementInfo(ref BatchBase<TDrawInfo>.ElementInfo elementInfo, IntPtr vertexPointer, IntPtr indexPointer, int vexterStartOffset)
Parameters
elementInfo
BatchBase<TDrawInfo>.ElementInfoThe structure containing the information about the element to draw.
vertexPointer
IntPtrThe pointer to the vertex array buffer to update.
indexPointer
IntPtrThe pointer to the index array buffer to update. This value is null if the index buffer used is static.
vexterStartOffset
intThe offset in the vertex buffer where the vertex of the element starts