An abstract Renderer for the SFML renderers. More...
Public Member Functions | |
SFMLRenderer () | |
Default constructor of SFMLRenderer. | |
virtual | ~SFMLRenderer () |
Destructor of SFMLRenderer. | |
void | setBlendMode (sf::Blend::Mode mode) |
Sets the blend mode of this SFMLRenderer. | |
virtual void | setBlending (BlendingMode blendMode) |
Sets the blending mode of this renderer. | |
void | setGroundCulling (bool cull) |
Sets whether the ground culling is enabled or not. | |
sf::Blend::Mode | getBlendMode () const |
Gets the blend mode of this SFMLRenderer. | |
bool | hasGroundCulling () const |
Tells whether the ground culling is enabled or not. | |
void | render (const Group &group) |
Renders a Group of particles. | |
Static Public Member Functions | |
static void | setZFactor (float zFactor) |
Sets the Z factor. | |
static float | getZFactor () |
Gets the Z factor. | |
static void | bindCurrentTarget (sf::RenderTarget &target) |
Binds a RenderTarget for rendering. | |
static void | releaseCurrentTarget () |
Releases the current RenderTarget. | |
static void | bindCurrentSystem (const SFMLSystem &system) |
Binds an SFMLSystem for rendering. | |
static void | releaseCurrentSystem () |
Releases the current SFMLSystem. | |
Static Protected Member Functions | |
static sf::RenderTarget * | getCurrentTarget () |
Gets the current RenderTarget. | |
static float | getViewZoom (ResizeMode mode) |
Gets the scale factor function of the current zoom and resize mode. |
An abstract Renderer for the SFML renderers.
All children of this renderer are meant to be used with the 2D engine of the SFML library.
As the rendering occurs in 2D the X and Y axis are the screen axis and the Z coordinate is subtracted to the Y coordinate to have classical 2D height effect.
The factor of Z to subtract to the Y can be adjusted with a call to the static method setZFactor(float). If the factor is 0, the Z coordinate is ignored.
Moreover, particles with a negative Z are not rendered as they are considered to be under the other 2D elements.
In the SFML library, a RenderTarget must be used for rendering. This RenderTarget can be set with a call to bindRenderTarget(const sf::RenderTarget&) and released with a call to releaseRenderTarget().
A call to render(const Group&) of a SFMLRenderer will not render anything if a RenderTarget is not set.
However using SFMLSystem to render particles with SFML will bind the target internally, freeing the user from setting it manually.
Definition at line 67 of file SPK_SFMLRenderer.h.
SFMLRenderer | ( | ) |
Default constructor of SFMLRenderer.
virtual ~SFMLRenderer | ( | ) | [virtual] |
Destructor of SFMLRenderer.
static void bindCurrentSystem | ( | const SFMLSystem & | system | ) | [static] |
Binds an SFMLSystem for rendering.
This method is used internally to tell the engine which SFMLSystem is currently being rendered.
system | : The SFMLSystem that is currently being rendered |
Definition at line 184 of file SPK_SFMLRenderer.h.
static void bindCurrentTarget | ( | sf::RenderTarget & | target | ) | [static] |
Binds a RenderTarget for rendering.
A RenderTarget is compulsory to render with SFML.
Rendering with SFMLSystem calls this method internally.
target | : the SFML RenderTarget to bind |
sf::Blend::Mode getBlendMode | ( | ) | const |
Gets the blend mode of this SFMLRenderer.
Definition at line 245 of file SPK_SFMLRenderer.h.
static sf::RenderTarget* getCurrentTarget | ( | ) | [static, protected] |
Gets the current RenderTarget.
static float getViewZoom | ( | ResizeMode | mode | ) | [static, protected] |
Gets the scale factor function of the current zoom and resize mode.
mode | : the resize mode used to compute the factor |
static float getZFactor | ( | ) | [static] |
bool hasGroundCulling | ( | ) | const |
Tells whether the ground culling is enabled or not.
For more information about ground culling see setGroundCulling(bool).
Definition at line 250 of file SPK_SFMLRenderer.h.
static void releaseCurrentSystem | ( | ) | [static] |
Releases the current SFMLSystem.
This method sets internally the SFMLSystem being rendered to NULL
Definition at line 194 of file SPK_SFMLRenderer.h.
static void releaseCurrentTarget | ( | ) | [static] |
Releases the current RenderTarget.
This method only sets the inner pointer to NULL.
void render | ( | const Group & | group | ) | [virtual] |
virtual void setBlending | ( | BlendingMode | blendMode | ) | [virtual] |
Sets the blending mode of this renderer.
This is a generic method that allows to set most common blending modes in a generic way. However renderers can implement method to give more control over the blending mode used.
blendMode | : the blending mode to use |
Implements Renderer.
void setBlendMode | ( | sf::Blend::Mode | mode | ) |
Sets the blend mode of this SFMLRenderer.
mode | : the blend mode of this SFMLRenderer in SFML style |
Definition at line 235 of file SPK_SFMLRenderer.h.
void setGroundCulling | ( | bool | cull | ) |
Sets whether the ground culling is enabled or not.
If it is enabled, all particles with and altitude (z coordinate) lower than zero will not be rendered.
This allows to simulate the activation of the zbuffer with the ground.
cull | : true to enable the ground culling, false to disable it |
Definition at line 240 of file SPK_SFMLRenderer.h.
static void setZFactor | ( | float | zFactor | ) | [static] |
Sets the Z factor.
The Z factor is the constant that will multiply the Z coordinate of a Particle position before being subtracted to the Y coordinate.
Note that the Z factor is static and in that way identical for all SFMLRenderers.
zFactor | : the Z factor |