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

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

Detailed Description

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.

Function Documentation

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.

Parameters
textureTexture which will be used to draw the sprites
max_sprite_countMaximum count of sprites which can be stored
See also
BLZ_DrawStatic
BLZ_FreeStatic
BLZ_GetOptionsStatic
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.

Parameters
batchThe batch to put the sprite in
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_PresentStatic
BLZ_CreateStatic
BLZAPIENTRY int BLZAPICALL BLZ_FreeBatchStatic ( struct BLZ_StaticBatch batch)

Destroys the specified static batch object.

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

See also
BLZ_CreateStatic
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).

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

Parameters
batchThe static batch to draw
transformMatrix4x4The 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.