Game Development Reference
In-Depth Information
Sprites will be drawn in the order the Draw calls were made when
End is called, the devices states are applied just before drawing.
ThismodeallowsmultipleSpriteBatchinstancestoissueDrawcalls
without the possibility of conflicting device states.
Deferred (default)
SameasDeferred,exceptspritesaresortedbydepthinfronttoback
orderbeforedrawing,usethismodewhendrawingopaquespritesat
varying depths.
FrontToBack
Same as BackToFront, except sprites are sorted by depth in back
to front order. Use this mode when rendering transparent sprites at
varying depths.
BackToFront
Graphics device settings are applied in the Begin call and sprites are
drawnwithineachDrawcall.Toavoidthepossibilityofintroducing
conflicting device states, there can only be one active SpriteBatch
instance.
Immediate
Same as Deferred, except sprites are sorted by texture before draw-
ing, this may improve performance when drawing non-overlapping
sprites of uniform depth.
Texture
DirectXTK provides a group of preset states that we may use in the majority of situations,
we access these through the CommonStates class.
DirectX::CommonStates states(device);
m_spriteBatch->Begin(DirectX::SpriteSortMode_Deferred, states.NonPremultiplied());
BlendState
The first parameter we need to provide to the Begin function is the BlendState. Com-
monStates gives us the following preset blend states:
Opaque
No alpha blending
Premultiplied alpha blending, recall for premultiplied alpha blending, textures
need to be preprocessed to multiply the alpha value with the respective pixel
color.
AlphaBlend (default)
Additive
Pixels colors are added, growing in intensity when pixels overlap.
Search WWH ::




Custom Search