blaze
|
Dynamic batched sprite drawing. More...
Enumerations | |
enum | BLZ_InitFlags { DEFAULT, NO_BUFFERING } |
Defines initialization flags for dynamic batches. More... | |
Functions | |
BLZAPIENTRY struct BLZ_SpriteBatch *BLZAPICALL | BLZ_CreateBatch (int max_buckets, int max_sprites_per_bucket, enum BLZ_InitFlags flags) |
Creates a new dynamic batch using the specified parameters. More... | |
BLZAPIENTRY int BLZAPICALL | BLZ_Draw (struct BLZ_SpriteBatch *batch, struct BLZ_Texture *texture, struct BLZ_Vector2 position, struct BLZ_Rectangle *srcRectangle, float rotation, struct BLZ_Vector2 *origin, struct BLZ_Vector2 *scale, struct BLZ_Vector4 color, enum BLZ_SpriteFlip effects) |
Adds a sprite to specified batch using specified parameters. More... | |
BLZAPIENTRY int BLZAPICALL | BLZ_FreeBatch (struct BLZ_SpriteBatch *batch) |
Destroys the specified dynamic batch object. More... | |
BLZAPIENTRY int BLZAPICALL | BLZ_GetOptions (struct BLZ_SpriteBatch *batch, int *max_buckets, int *max_sprites_per_bucket, enum BLZ_InitFlags *flags) |
Reads options specified in BLZ_CreateBatch for the specified batch object. More... | |
BLZAPIENTRY int BLZAPICALL | BLZ_LowerDraw (struct BLZ_SpriteBatch *batch, GLuint texture, struct BLZ_SpriteQuad *quad) |
Lower level dynamic batching function, called by BLZ_Draw. More... | |
BLZAPIENTRY int BLZAPICALL | BLZ_Present (struct BLZ_SpriteBatch *batch) |
Draws everything from the specified dynamic batch to screen. More... | |
Dynamic batched sprite drawing.
Use it when you want to efficiently draw many sprites which share textures (or texture atlases). If you want to draw a small number of different sprites which will not benefit of batching (grouping) them, see Immediate drawing module. If you want to efficiently draw non-changing geometry like tilemaps, see the Static drawing module.
enum BLZ_InitFlags |
Defines initialization flags for dynamic batches.
Enumerator | |
---|---|
DEFAULT |
Default flags. |
NO_BUFFERING |
Disables sprite vertex array buffering, which lowers GPU memory usage, but sacrifices sprite drawing speed. |
BLZAPIENTRY struct BLZ_SpriteBatch* BLZAPICALL BLZ_CreateBatch | ( | int | max_buckets, |
int | max_sprites_per_bucket, | ||
enum BLZ_InitFlags | flags | ||
) |
Creates a new dynamic batch using the specified parameters.
max_buckets | Defines maximum sprite buckets. A bucket uses same texture for all sprites and is limited by max_sprites_per_batch. |
max_sprites_per_bucket | Defines maximum sprite count in one bucket. |
flags | Initialization flags. |
BLZAPIENTRY int BLZAPICALL BLZ_Draw | ( | struct BLZ_SpriteBatch * | batch, |
struct BLZ_Texture * | texture, | ||
struct BLZ_Vector2 | position, | ||
struct BLZ_Rectangle * | srcRectangle, | ||
float | rotation, | ||
struct BLZ_Vector2 * | origin, | ||
struct BLZ_Vector2 * | scale, | ||
struct BLZ_Vector4 | color, | ||
enum BLZ_SpriteFlip | effects | ||
) |
Adds a sprite to specified batch using specified parameters.
batch | The batch to put the sprite in |
texture | Sprite texture |
position | Position of the sprite (top-left corner if origin is NULL) |
srcRectangle | Part of the source texture to draw defined in pixels, or NULL if the whole texture should be drawn |
rotation | Rotation of the sprite in clockwise direction in radians |
origin | The point around which the sprite should be positioned and rotated, if NULL, top-left corner (0, 0) will be used |
scale | Scale in X and Y directions, if NULL, defaults to (1,1) |
color | Color to apply to the sprite (color gets multiplied if default shader is used) |
effects | Defines if the sprite should be flipped in any direction |
BLZAPIENTRY int BLZAPICALL BLZ_FreeBatch | ( | struct BLZ_SpriteBatch * | batch | ) |
Destroys the specified dynamic batch object.
BLZAPIENTRY int BLZAPICALL BLZ_GetOptions | ( | struct BLZ_SpriteBatch * | batch, |
int * | max_buckets, | ||
int * | max_sprites_per_bucket, | ||
enum BLZ_InitFlags * | flags | ||
) |
Reads options specified in BLZ_CreateBatch for the specified batch object.
BLZAPIENTRY int BLZAPICALL BLZ_LowerDraw | ( | struct BLZ_SpriteBatch * | batch, |
GLuint | texture, | ||
struct BLZ_SpriteQuad * | quad | ||
) |
BLZAPIENTRY int BLZAPICALL BLZ_Present | ( | struct BLZ_SpriteBatch * | batch | ) |
Draws everything from the specified dynamic batch to screen.