Gamedev Framework (gf)  0.3.0
A C++11 framework for 2D games
Public Member Functions | List of all members
gf::SpriteBatch Class Reference

A sprite batch. More...

#include <gf/SpriteBatch.h>

Public Member Functions

 SpriteBatch (RenderTarget &target)
 Constructor. More...
 
void begin ()
 Begin the batch. More...
 
void draw (Sprite &sprite, const RenderStates &states=RenderStates())
 Add a sprite to the batch. More...
 
void end ()
 End the batch. More...
 

Detailed Description

A sprite batch.

A sprite batch is responsible for minimizing the number of draw calls by concatenating the different calls for sprites.

Before using a sprite batch, you have to call begin(), then call draw() for each sprite you want to draw, and finally call end().

gf::SpriteBatch batch(renderer);
batch.begin();
batch.draw(sprite1);
batch.draw(sprite2);
batch.draw(sprite3);
batch.end();
See also
gf::Sprite

Constructor & Destructor Documentation

gf::SpriteBatch::SpriteBatch ( RenderTarget target)

Constructor.

Parameters
targetA render target where the sprites will be drawn

Member Function Documentation

void gf::SpriteBatch::begin ( )

Begin the batch.

void gf::SpriteBatch::draw ( Sprite sprite,
const RenderStates states = RenderStates() 
)

Add a sprite to the batch.

You must call begin() before calling this function, and end() once you have finished to draw the sprites.

Parameters
spriteThe sprite to draw
statesThe render states
void gf::SpriteBatch::end ( )

End the batch.