All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Luminous::SpriteRenderer Class Reference

This class implements a simple particle system. More...

#include <Luminous/SpriteRenderer.hpp>

Inheritance diagram for Luminous::SpriteRenderer:
Patterns::NotCopyable

Classes

struct  Sprite
 Individual sprite. More...
 

Public Types

typedef std::vector< SpriteSpriteVector
 The container type where the sprites are stored.
 

Public Member Functions

const BlendModeblendMode () const
 Blend mode used during rendering. More...
 
void createFuzzyTexture (int dim, float centerDotSize=0.25f, float haloweight=0.75f, float halodescent=1.0f)
 Create a blurry texture Creates a basic square texture with radial gradient pattern. More...
 
void render (Luminous::RenderContext &r) const
 Renders the sprites.
 
void resize (size_t n)
 Resize the sprite buffer.
 
void setBlendMode (const Luminous::BlendMode &mode)
 Set the blend mode used for rendering the particles. More...
 
void setImage (const Luminous::Image &image)
 Sets the texture that is used in the rendering process.
 
void setVelocityScale (float velscale)
 Set the velocity scaling factor. More...
 
size_t spriteCount () const
 Returns the number of allocated sprites.
 
 SpriteRenderer ()
 Constructor.
 
SpriteVectorsprites ()
 Return the vector containing the sprites.
 
void uploadData ()
 
float velocityScale () const
 Velocity scaling factor is used to stretch the particles along the velocity vector during rendering. More...
 
 ~SpriteRenderer ()
 Destructor.
 

Detailed Description

This class implements a simple particle system.

This class can be used to draw a great number of sprites on the screen. It relies on geometry, vertex, and pixels shaders to to increase its performance. Consequently it may not run on outdated or very low-end hardware.

The maximum number of particles depends on the hardware, and the particle update logic. Typically the limiting factor is the CPU-based calculation of the particle parameters.

Member Function Documentation

const BlendMode& Luminous::SpriteRenderer::blendMode ( ) const

Blend mode used during rendering.

Returns
blend mode used
void Luminous::SpriteRenderer::createFuzzyTexture ( int  dim,
float  centerDotSize = 0.25f,
float  haloweight = 0.75f,
float  halodescent = 1.0f 
)

Create a blurry texture Creates a basic square texture with radial gradient pattern.

Parameters
dimtexture dimensions
centerDotSizesize of the opaque center dot
haloweightweighting factor for the radial gradient
halodescentfactor for how fast the gradient drops to zero
void Luminous::SpriteRenderer::setBlendMode ( const Luminous::BlendMode mode)

Set the blend mode used for rendering the particles.

Parameters
modeblend mode
void Luminous::SpriteRenderer::setVelocityScale ( float  velscale)

Set the velocity scaling factor.

Parameters
velscalevelocity scaling
See Also
velocityScale
float Luminous::SpriteRenderer::velocityScale ( ) const

Velocity scaling factor is used to stretch the particles along the velocity vector during rendering.

Set to zero to disable stretching. Default value is zero.

Returns
velocity scaling factor