Harlinn.Windows 0.1
Loading...
Searching...
No Matches
Harlinn::Windows::Graphics::SpriteBatch Class Reference

Represents a single group of sprites with their associated drawing properties. More...

#include <HWGraphics.h>

Inheritance diagram for Harlinn::Windows::Graphics::SpriteBatch:
[legend]
Collaboration diagram for Harlinn::Windows::Graphics::SpriteBatch:
[legend]

Private Member Functions

void AddSprites (UINT32 spriteCount, const D2D1_RECT_F *destinationRectangles, const D2D1_RECT_U *sourceRectangles=nullptr, const D2D1_COLOR_F *colors=nullptr, const D2D1_MATRIX_3X2_F *transforms=nullptr, UINT32 destinationRectanglesStride=sizeof(D2D1_RECT_F), UINT32 sourceRectanglesStride=sizeof(D2D1_RECT_U), UINT32 colorsStride=sizeof(D2D1_COLOR_F), UINT32 transformsStride=sizeof(D2D1_MATRIX_3X2_F)) const
 Adds the given sprites to the end of this sprite batch.
 
void SetSprites (UINT32 startIndex, UINT32 spriteCount, const D2D1_RECT_F *destinationRectangles=nullptr, const D2D1_RECT_U *sourceRectangles=nullptr, const D2D1_COLOR_F *colors=nullptr, const D2D1_MATRIX_3X2_F *transforms=nullptr, UINT32 destinationRectanglesStride=sizeof(D2D1_RECT_F), UINT32 sourceRectanglesStride=sizeof(D2D1_RECT_U), UINT32 colorsStride=sizeof(D2D1_COLOR_F), UINT32 transformsStride=sizeof(D2D1_MATRIX_3X2_F)) const
 Updates the properties of the specified sprites in this sprite batch. Providing a null value for any property will leave that property unmodified for that sprite.
 
void GetSprites (UINT32 startIndex, UINT32 spriteCount, D2D1_RECT_F *destinationRectangles=nullptr, D2D1_RECT_U *sourceRectangles=nullptr, D2D1_COLOR_F *colors=nullptr, D2D1_MATRIX_3X2_F *transforms=nullptr) const
 Retrieves the specified subset of sprites from this sprite batch. For the best performance, use nullptr for properties that you do not need to retrieve.
 
UINT32 GetSpriteCount () const
 Retrieves the number of sprites in the sprite batch.
 
void Clear () const
 Removes all sprites from this sprite batch.
 

Additional Inherited Members

- Public Types inherited from Harlinn::Common::Core::Unknown
typedef IUnknown InterfaceType
 
- Public Member Functions inherited from Harlinn::Windows::Graphics::Resource
template<typename T = Factory>
requires std::is_base_of_v< Factory, T>
T GetFactory ()
 
- Public Member Functions inherited from Harlinn::Common::Core::Unknown
constexpr Unknown () noexcept
 
 Unknown (IUnknown *unknown, bool addref=false) noexcept
 
 Unknown (REFIID iid, const Unknown &unknown, bool throwIfNoInterface=true)
 
 Unknown (const Unknown &other) noexcept
 
 Unknown (Unknown &&other) noexcept
 
 ~Unknown () noexcept
 
constexpr operator bool () const noexcept
 
Unknownoperator= (const Unknown &other) noexcept
 
Unknownoperator= (Unknown &&other) noexcept
 
void swap (Unknown &other) noexcept
 
void ResetPtr (IUnknown *other=nullptr, bool addRef=false) noexcept
 
Unknownoperator= (nullptr_t)
 
IUnknown * Detach ()
 
template<typename T >
requires std::is_base_of_v<Unknown, T >
T As () const
 
template<typename T >
requires std::is_base_of_v<Unknown, T>
bool Is () const noexcept
 
template<typename T >
requires std::is_base_of_v<IUnknown, T>
ComPtr< TAs () const
 
template<typename T >
requires std::is_base_of_v<IUnknown, T>
bool Is () const noexcept
 This function can be used to detect if an object supports a particular COM interface derived from IUnknown.
 
template<typename T = IUnknown>
TGetInterfacePointer () const noexcept
 
bool QueryInterface (REFIID riid, void **itf) const
 Queries a COM object for a pointer to one of its interface; identifying the interface by a reference to its interface identifier (IID). If the COM object implements the interface, then it returns a pointer to that interface after calling IUnknown::AddRef on it.
 
template<typename T >
requires std::is_base_of_v<IUnknown, T>
bool QueryInterface (T **itf) const
 
constexpr bool operator== (const Unknown &other) const noexcept
 
constexpr bool operator!= (const Unknown &other) const noexcept
 
constexpr bool operator== (const IUnknown *other) const noexcept
 
constexpr bool operator!= (const IUnknown *other) const noexcept
 
- Static Public Member Functions inherited from Harlinn::Common::Core::Unknown
template<typename T >
requires std::is_base_of_v<Unknown, T>
static T CoCreateInstanceFromClassId (const CLSID &clsid, DWORD classContext=CLSCTX_INPROC_SERVER)
 
template<typename T >
requires std::is_base_of_v<Unknown, T>
static T CoCreateInstanceFromClassId (const wchar_t *clsid, DWORD classContext=CLSCTX_INPROC_SERVER)
 
template<typename T >
requires std::is_base_of_v<Unknown, T>
static T CoCreateInstanceFromClassId (const WideString &clsid, DWORD classContext=CLSCTX_INPROC_SERVER)
 
template<typename T >
requires std::is_base_of_v<Unknown, T>
static T CoCreateInstanceFromProgId (const wchar_t *progId, DWORD classContext=CLSCTX_INPROC_SERVER)
 
template<typename T >
requires std::is_base_of_v<Unknown, T>
static T CoCreateInstanceFromProgId (const WideString &progId, DWORD classContext=CLSCTX_INPROC_SERVER)
 
template<typename T >
requires std::is_base_of_v<Unknown, T>
static T CoCreateInstanceFromDll (const ModuleHandle &dll, const CLSID &clsid)
 
- Protected Attributes inherited from Harlinn::Common::Core::Unknown
IUnknown * unknown_
 

Detailed Description

Represents a single group of sprites with their associated drawing properties.

Member Function Documentation

◆ AddSprites()

void Harlinn::Windows::Graphics::SpriteBatch::AddSprites ( UINT32 spriteCount,
const D2D1_RECT_F * destinationRectangles,
const D2D1_RECT_U * sourceRectangles = nullptr,
const D2D1_COLOR_F * colors = nullptr,
const D2D1_MATRIX_3X2_F * transforms = nullptr,
UINT32 destinationRectanglesStride = sizeof( D2D1_RECT_F ),
UINT32 sourceRectanglesStride = sizeof( D2D1_RECT_U ),
UINT32 colorsStride = sizeof( D2D1_COLOR_F ),
UINT32 transformsStride = sizeof( D2D1_MATRIX_3X2_F ) ) const
inlineprivate

Adds the given sprites to the end of this sprite batch.

Parameters
spriteCountThe number of sprites to be added. This determines how many strides into each given array Direct2D will read.
destinationRectanglesA pointer to an array containing the destination rectangles specifying where to draw the sprites on the destination device context.
sourceRectanglesA pointer to an array containing the source rectangles specifying the regions of the source bitmap to draw as sprites. Direct2D will use the entire source bitmap for sprites that are assigned a null value or the InfiniteRectU. If this parameter is omitted entirely or set to a null value, then Direct2D will use the entire source bitmap for all the added sprites.
colors

A pointer to an array containing the colors to apply to each sprite. The output color is the result of component-wise multiplication of the source bitmap color and the provided color. The output color is not clamped.

Direct2D will not change the color of sprites that are assigned a null value. If this parameter is omitted entirely or set to a null value, then Direct2D will not change the color of any of the added sprites.

Parameters
transforms

A pointer to an array containing the transforms to apply to each sprite’s destination rectangle.

Direct2D will not transform the destination rectangle of any sprites that are assigned a null value. If this parameter is omitted entirely or set to a null value, then Direct2D will not transform the destination rectangle of any of the added sprites.

Parameters
destinationRectanglesStrideSpecifies the distance, in bytes, between each rectangle in the destinationRectangles array. If you provide a stride of 0, then the same destination rectangle will be used for each added sprite.
sourceRectanglesStrideSpecifies the distance, in bytes, between each rectangle in the sourceRectangles array (if that array is given). If you provide a stride of 0, then the same source rectangle will be used for each added sprite.
colorsStrideSpecifies the distance, in bytes, between each color in the colors array (if that array is given). If you provide a stride of 0, then the same color will be used for each added sprite.
transformsStrideSpecifies the distance, in bytes, between each transform in the transforms array (if that array is given). If you provide a stride of 0, then the same transform will be used for each added sprite.

In Direct2D, a sprite is defined by four properties: a destination rectangle, a source rectangle, a color, and a transform. Destination rectangles are mandatory, but the remaining properties are optional.

Always omit or pass a null value for properties you do not wish to use. This allows Direct2D to avoid storing values for those properties and to skip their handling entirely, which improves drawing speed. For example, suppose you have a batch of 500 sprites, and you do not wish to transform any of their destination rectangles. Rather than passing an array of identity matrices, simply omit the transforms parameter. This allows Direct2D to avoid storing any transforms and will yield the fastest drawing performance. On the other hand, if any sprite in the batch has any value set for a property, then internally Direct2D must allocate space for that property array and assign every sprite a value for that property (even if it’s just the default value).

◆ Clear()

void Harlinn::Windows::Graphics::SpriteBatch::Clear ( ) const
inlineprivate

Removes all sprites from this sprite batch.

◆ GetSpriteCount()

UINT32 Harlinn::Windows::Graphics::SpriteBatch::GetSpriteCount ( ) const
inlineprivate

Retrieves the number of sprites in the sprite batch.

Returns
The number of sprites in this sprite batch.

◆ GetSprites()

void Harlinn::Windows::Graphics::SpriteBatch::GetSprites ( UINT32 startIndex,
UINT32 spriteCount,
D2D1_RECT_F * destinationRectangles = nullptr,
D2D1_RECT_U * sourceRectangles = nullptr,
D2D1_COLOR_F * colors = nullptr,
D2D1_MATRIX_3X2_F * transforms = nullptr ) const
inlineprivate

Retrieves the specified subset of sprites from this sprite batch. For the best performance, use nullptr for properties that you do not need to retrieve.

Parameters
startIndexThe index of the first sprite in this sprite batch to retrieve.
spriteCountThe number of sprites to retrieve.
destinationRectanglesWhen this method returns, contains a pointer to an array containing the destination rectangles for the retrieved sprites.
sourceRectangles

When this method returns, contains a pointer to an array containing the source rectangles for the retrieved sprites.

The InfiniteRectU is returned for any sprites that were not assigned a source rectangle.

Parameters
colors

When this method returns, contains a pointer to an array containing the colors to be applied to the retrieved sprites.

The color {1.0f, 1.0f, 1.0f, 1.0f} is returned for any sprites that were not assigned a color.

Parameters
transforms

When this method returns, contains a pointer to an array containing the transforms to be applied to the retrieved sprites.

The identity matrix is returned for any sprites that were not assigned a transform.

◆ SetSprites()

void Harlinn::Windows::Graphics::SpriteBatch::SetSprites ( UINT32 startIndex,
UINT32 spriteCount,
const D2D1_RECT_F * destinationRectangles = nullptr,
const D2D1_RECT_U * sourceRectangles = nullptr,
const D2D1_COLOR_F * colors = nullptr,
const D2D1_MATRIX_3X2_F * transforms = nullptr,
UINT32 destinationRectanglesStride = sizeof( D2D1_RECT_F ),
UINT32 sourceRectanglesStride = sizeof( D2D1_RECT_U ),
UINT32 colorsStride = sizeof( D2D1_COLOR_F ),
UINT32 transformsStride = sizeof( D2D1_MATRIX_3X2_F ) ) const
inlineprivate

Updates the properties of the specified sprites in this sprite batch. Providing a null value for any property will leave that property unmodified for that sprite.

Parameters
startIndexThe index of the first sprite in this sprite batch to update.
spriteCountThe number of sprites to update with new properties. This determines how many strides into each given array Direct2D will read.
destinationRectanglesA pointer to an array containing the destination rectangles specifying where to draw the sprites on the destination device context.
sourceRectangles

A pointer to an array containing the source rectangles specifying the regions of the source bitmap to draw as sprites.

Direct2D will use the entire source bitmap for sprites that are assigned a null value or the InfiniteRectU. If this parameter is omitted entirely or set to a null value, then Direct2D will use the entire source bitmap for all the updated sprites.

Parameters
colors

A pointer to an array containing the colors to apply to each sprite. The output color is the result of component-wise multiplication of the source bitmap color and the provided color. The output color is not clamped.

Direct2D will not change the color of sprites that are assigned a null value. If this parameter is omitted entirely or set to a null value, then Direct2D will not change the color of any of the updated sprites.

Parameters
transforms

A pointer to an array containing the transforms to apply to each sprite’s destination rectangle.

Direct2D will not transform the destination rectangle of any sprites that are assigned a null value. If this parameter is omitted entirely or set to a null value, then Direct2D will not transform the destination rectangle of any of the updated sprites.

Parameters
destinationRectanglesStrideSpecifies the distance, in bytes, between each rectangle in the destinationRectangles array. If you provide a stride of 0, then the same destination rectangle will be used for each updated sprite.
sourceRectanglesStrideSpecifies the distance, in bytes, between each rectangle in the sourceRectangles array (if that array is given). If you provide a stride of 0, then the same source rectangle will be used for each updated sprite.
colorsStrideSpecifies the distance, in bytes, between each color in the colors array (if that array is given). If you provide a stride of 0, then the same color will be used for each updated sprite.
transformsStrideSpecifies the distance, in bytes, between each transform in the transforms array (if that array is given). If you provide a stride of 0, then the same transform will be used for each updated sprite.

The documentation for this class was generated from the following file: