blaze
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules
Dynamic drawing

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...
 

Detailed Description

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.

Enumeration Type Documentation

Defines initialization flags for dynamic batches.

See also
BLZ_CreateBatch
BLZ_Draw
Enumerator
DEFAULT 

Default flags.

NO_BUFFERING 

Disables sprite vertex array buffering, which lowers GPU memory usage, but sacrifices sprite drawing speed.

Function Documentation

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.

Parameters
max_bucketsDefines maximum sprite buckets. A bucket uses same texture for all sprites and is limited by max_sprites_per_batch.
max_sprites_per_bucketDefines maximum sprite count in one bucket.
flagsInitialization flags.
Returns
Pointer to a newly created dynamic batch object.
See also
BLZ_Draw
BLZ_GetOptions
BLZ_FreeBatch
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.

Parameters
batchThe batch to put the sprite in
textureSprite texture
positionPosition of the sprite (top-left corner if origin is NULL)
srcRectanglePart of the source texture to draw defined in pixels, or NULL if the whole texture should be drawn
rotationRotation of the sprite in clockwise direction in radians
originThe point around which the sprite should be positioned and rotated, if NULL, top-left corner (0, 0) will be used
scaleScale in X and Y directions, if NULL, defaults to (1,1)
colorColor to apply to the sprite (color gets multiplied if default shader is used)
effectsDefines if the sprite should be flipped in any direction
See also
BLZ_Present
BLZ_CreateBatch
BLZAPIENTRY int BLZAPICALL BLZ_FreeBatch ( struct BLZ_SpriteBatch batch)

Destroys the specified dynamic batch object.

See also
BLZ_CreateBatch
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.

See also
BLZ_CreateBatch
BLZAPIENTRY int BLZAPICALL BLZ_LowerDraw ( struct BLZ_SpriteBatch batch,
GLuint  texture,
struct BLZ_SpriteQuad quad 
)

Lower level dynamic batching function, called by BLZ_Draw.

You can pass your own quad (fullscreen one, for example).

See also
BLZ_Draw
BLZAPIENTRY int BLZAPICALL BLZ_Present ( struct BLZ_SpriteBatch batch)

Draws everything from the specified dynamic batch to screen.