blaze
|
Static batched sprite drawing. More...
Functions | |
BLZAPIENTRY struct BLZ_StaticBatch BLZAPICALL * | BLZ_CreateStatic (struct BLZ_Texture *texture, int max_sprite_count) |
Creates a 'static' batch object. More... | |
BLZAPIENTRY int BLZAPICALL | BLZ_DrawStatic (struct BLZ_StaticBatch *batch, 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_FreeBatchStatic (struct BLZ_StaticBatch *batch) |
Destroys the specified static batch object. More... | |
BLZAPIENTRY int BLZAPICALL | BLZ_GetOptionsStatic (struct BLZ_StaticBatch *batch, int *max_sprite_count) |
Reads options specified in BLZ_CreateStatic for the specified static batch object. More... | |
BLZAPIENTRY int BLZAPICALL | BLZ_LowerDrawStatic (struct BLZ_StaticBatch *batch, struct BLZ_SpriteQuad *quad) |
Lower level static batching function, called by BLZ_DrawStatic. More... | |
BLZAPIENTRY int BLZAPICALL | BLZ_PresentStatic (struct BLZ_StaticBatch *batch, GLfloat *transformMatrix4x4) |
Draws everything from the specified static batch to screen. More... | |
Static batched sprite drawing.
Use it when you want to efficiently draw static things like tilemaps. On the first BLZ_PresentStatic call, the sprite data will be 'baked' into GPU memory and then become non-modifiable. 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 changing geometry, see the Dynamic drawing module.
BLZAPIENTRY struct BLZ_StaticBatch BLZAPICALL* BLZ_CreateStatic | ( | struct BLZ_Texture * | texture, |
int | max_sprite_count | ||
) |
Creates a 'static' batch object.
The difference from the dynamic one is that when this batch is drawn for the first time, the sprites will be 'baked' into vertex array and cannot be modified. It's useful for static level geometry like tilemaps, because individual tile positions shouldn't be calculated each frame, but they should be transformed as a whole (by camera, for example). In other words, it lowers CPU usage.
texture | Texture which will be used to draw the sprites |
max_sprite_count | Maximum count of sprites which can be stored |
BLZAPIENTRY int BLZAPICALL BLZ_DrawStatic | ( | struct BLZ_StaticBatch * | batch, |
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 |
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_FreeBatchStatic | ( | struct BLZ_StaticBatch * | batch | ) |
Destroys the specified static batch object.
BLZAPIENTRY int BLZAPICALL BLZ_GetOptionsStatic | ( | struct BLZ_StaticBatch * | batch, |
int * | max_sprite_count | ||
) |
Reads options specified in BLZ_CreateStatic for the specified static batch object.
BLZAPIENTRY int BLZAPICALL BLZ_LowerDrawStatic | ( | struct BLZ_StaticBatch * | batch, |
struct BLZ_SpriteQuad * | quad | ||
) |
Lower level static batching function, called by BLZ_DrawStatic.
You can pass your own quad (fullscreen one, for example).
BLZAPIENTRY int BLZAPICALL BLZ_PresentStatic | ( | struct BLZ_StaticBatch * | batch, |
GLfloat * | transformMatrix4x4 | ||
) |
Draws everything from the specified static batch to screen.
If it's the first time when the batch is drawn, 'bakes' the sprites into GPU memory and forbids modification.
batch | The static batch to draw |
transformMatrix4x4 | The transformation matrix. If NULL, identity matrix is used (so the sprites will be drawn as specified by BLZ_DrawStatic calls). Pass a custom matrix to implement camera functionality. |