![]() |
MAGE
v0.171.0
Matthias Advanced Game Engine
|
Public Member Functions | |
Impl (ID3D11Device &device, ID3D11DeviceContext &device_context) | |
Impl (const Impl &sprite_batch)=delete | |
Impl (Impl &&sprite_batch) noexcept | |
~Impl () | |
Impl & | operator= (const Impl &sprite_batch)=delete |
Impl & | operator= (Impl &&sprite_batch) noexcept |
void | Begin (SpriteSortMode sort_mode=SpriteSortMode::Deferred) |
void XM_CALLCONV | Draw (ID3D11ShaderResourceView *texture, FXMVECTOR color, SpriteEffect effects, const SpriteTransform2D &transform, const RECT *source=nullptr) |
void | End () |
Private Member Functions | |
void | BindFixedState () |
void | FlushBatch () |
void | SortSprites () |
void | Render (ID3D11ShaderResourceView *texture, const SpriteInfo *const *sprites, std::size_t nb_sprites) |
void XM_CALLCONV | PrepareSprite (const SpriteInfo &sprite, VertexPositionColorTexture *vertices, FXMVECTOR texture_size, FXMVECTOR inverse_texture_size) noexcept |
Private Attributes | |
std::reference_wrapper< ID3D11DeviceContext > | m_device_context |
UniquePtr< SpriteBatchMesh > | m_mesh |
std::size_t | m_mesh_position |
bool | m_in_begin_end_pair |
SpriteSortMode | m_sort_mode |
AlignedVector< SpriteInfo > | m_sprites |
std::vector< const SpriteInfo *> | m_sorted_sprites |
Static Private Attributes | |
static constexpr std::size_t | s_initial_capacity = 64u |
A class of sprite batches.
|
explicit |
Constructs a sprite batch.
[in,out] | device | A reference to the device. |
[in,out] | device_context | A reference to the device context. |
|
delete |
Constructs a sprite batch from the given sprite batch.
[in] | sprite_batch | A reference to the sprite batch to copy. |
|
defaultnoexcept |
Constructs a sprite batch by moving the given sprite batch.
[in] | sprite_batch | A reference to the sprite batch to move. |
|
default |
Destructs this sprite batch.
void mage::rendering::SpriteBatch::Impl::Begin | ( | SpriteSortMode | sort_mode = SpriteSortMode::Deferred | ) |
Begins the processing of a batch of sprites.
[in] | sort_mode | A reference to the sprite sorting mode for the whole batch of sprites. |
|
private |
Binds the fixed state of this sprite batch.
void XM_CALLCONV mage::rendering::SpriteBatch::Impl::Draw | ( | ID3D11ShaderResourceView * | texture, |
FXMVECTOR | color, | ||
SpriteEffect | effects, | ||
const SpriteTransform2D & | transform, | ||
const RECT * | source = nullptr |
||
) |
Draws a sprite.
[in] | texture | A pointer to the shader resource view of the texture to draw. |
[in] | color | The (linear) RGBA color. |
[in] | effects | The sprite effects to apply. |
[in] | transform | A reference to the sprite transform. |
[in] | source | A pointer the rectangular subregion of the texture. |
void mage::rendering::SpriteBatch::Impl::End | ( | ) |
Ends the processing of a batch of sprites.
|
private |
Flushes a batch of sprites for rendering if non-immediate rendering is required for the current batch of sprites. Otherwise, the sprites in the current batch are rendered immediately.
Sprites are sorted based on the sprite sorting mode and adjacent sprites are grouped for rendering if sharing the same texture.
Copies the given sprite batch to this sprite batch.
[in] | sprite_batch | A reference to the sprite batch to copy. |
|
defaultnoexcept |
Moves the given sprite batch to this sprite batch.
[in] | sprite_batch | A reference to the sprite batch to move. |
|
privatenoexcept |
Prepares a single sprite for rendering.
nullptr
. [in] | sprite | A reference to the sprite info data. |
[in] | vertices | A pointer to the vertices for the sprite. |
[in] | texture_size | The size of the texture (in the number of texels). |
[in] | inverse_texture_size | The inverse of texture_size. |
|
private |
Draws a subbatch of sprites of the current batch of sprites of this sprite batch.
nullptr
. nullptr
. [in] | texture | A pointer to the shader resource view of the texture that needs to be rendered. |
[in] | sprites | A pointer to the sprite info data pointers of the sprites which need to be rendered. |
[in] | nb_sprites | The number of sprites which need to be rendered. |
|
private |
Sorts the sprites of the current batch according to the sprite sorting mode of this sprite batch.
|
private |
A reference to the device context of this sprite batch.
|
private |
A flag indicating whether this sprite batch is in a begin/end pair for processing sprites.
|
private |
A pointer to the sprite batch mesh used by this sprite batch for drawing the sprites onto.
|
private |
The current position in the mesh of this sprite batch for adding sprite vertices.
|
private |
The sprite sorting mode used by this sprite batch for deciding on the draw order of sprites in the current btach of sprites.
|
private |
A vector containing the pointers to the sorted sprites of this sprite batch.
|
private |
A vector containing the sprites waiting to be drawn by this sprite batch.
|
staticprivate |
The initial capacity of the vector containing the sprites waiting to be drawn by a sprite batch.