Handles the low-level rendering (states and geometry) More...
#include <Renderer.hpp>
Classes | |
struct | States |
Public Types | |
enum | PrimitiveType { TriangleList, TriangleStrip, TriangleFan, QuadList } |
Types of primitives to be rendererd. More... | |
Public Member Functions | |
Renderer (RenderTarget &target) | |
Construct the renderer with its owner render target. | |
void | Initialize () |
Initialize the renderer (set the default states, etc.) | |
void | SaveGLStates () |
Save the current OpenGL render states and matrices. | |
void | RestoreGLStates () |
Restore the previously saved OpenGL render states and matrices. | |
void | Clear (const Color &color) |
Clear the color buffer. | |
void | PushStates () |
Save the current render states. | |
void | PopStates () |
Restore the previously saved render states. | |
void | SetModelView (const Matrix3 &matrix) |
Set a new model-view matrix. | |
void | ApplyModelView (const Matrix3 &matrix) |
Combine a new model-view matrix with the current one. | |
void | SetProjection (const Matrix3 &matrix) |
Set a new projection matrix. | |
void | SetColor (const Color &color) |
Set the current global color. | |
void | ApplyColor (const Color &color) |
Modulate the current global color with a new one. | |
void | SetViewport (const IntRect &viewport) |
Set the current viewport. | |
void | SetBlendMode (Blend::Mode mode) |
Set the current alpha-blending mode. | |
void | SetTexture (const Texture *texture) |
Set the current texture. | |
void | SetShader (const Shader *shader) |
Set the current shader. | |
void | Begin (PrimitiveType type) |
Begin rendering a new geometry batch. | |
void | End () |
End the current geometry batch and render it. | |
void | AddVertex (float x, float y) |
Add a new vertex (position only) | |
void | AddVertex (float x, float y, float u, float v) |
Add a new vertex (position + texture coordinates) | |
void | AddVertex (float x, float y, const Color &color) |
Add a new vertex (position + color) | |
void | AddVertex (float x, float y, float u, float v, const Color &color) |
Add a new vertex (position + texture coordinates + color) | |
Static Private Member Functions | |
static void | EnsureGlContext () |
Handles the low-level rendering (states and geometry)
sf::Renderer is the abstraction layer between SFML code and the low-level drawing API (OpenGL).
It manages render states efficiently, and provides a lightweight abstraction for rendering geometry.
The purpose of this class is to provide a single abstract entry point for everything related to low-level rendering. Hiding everything behind sf::Renderer makes optimizing easy, as well as porting to other technologies in the future (like OpenGL ES or OpenGL 3.x).
This class is mainly meant for internal usage, you should never care about it unless you write your own sf::Drawable class that uses raw geometry in its Render function.
Definition at line 48 of file Renderer.hpp.
Types of primitives to be rendererd.
Definition at line 56 of file Renderer.hpp.
sf::Renderer::Renderer | ( | RenderTarget & | target | ) |
Construct the renderer with its owner render target.
target | Owner render target |
void sf::Renderer::AddVertex | ( | float | x, |
float | y | ||
) |
Add a new vertex (position only)
This function adds a new vertex to the current batch. This is equivalent to calling AddVertex(x, y, 0, 0, Color::White).
x | X coordinate of the vertex |
y | Y coordinate of the vertex |
void sf::Renderer::AddVertex | ( | float | x, |
float | y, | ||
float | u, | ||
float | v | ||
) |
Add a new vertex (position + texture coordinates)
This function adds a new vertex to the current batch. This is equivalent to calling AddVertex(x, y, u, v, Color::White).
x | X coordinate of the vertex |
y | Y coordinate of the vertex |
u | X texture coordinate of the vertex |
v | Y texture coordinate of the vertex |
void sf::Renderer::AddVertex | ( | float | x, |
float | y, | ||
const Color & | color | ||
) |
Add a new vertex (position + color)
This function adds a new vertex to the current batch. This is equivalent to calling AddVertex(x, y, 0, 0, color).
x | X coordinate of the vertex |
y | Y coordinate of the vertex |
color | Color of the vertex |
void sf::Renderer::AddVertex | ( | float | x, |
float | y, | ||
float | u, | ||
float | v, | ||
const Color & | color | ||
) |
Add a new vertex (position + texture coordinates + color)
This function adds a new vertex to the current batch.
x | X coordinate of the vertex |
y | Y coordinate of the vertex |
u | X texture coordinate of the vertex |
v | Y texture coordinate of the vertex |
color | Color of the vertex |
void sf::Renderer::ApplyColor | ( | const Color & | color | ) |
void sf::Renderer::ApplyModelView | ( | const Matrix3 & | matrix | ) |
Combine a new model-view matrix with the current one.
matrix | Model-view matrix to combine |
void sf::Renderer::Begin | ( | PrimitiveType | type | ) |
Begin rendering a new geometry batch.
You need to call End() to complete the batch and trigger the actual rendering of the geometry that you passed between Begin() and End().
Usage:
renderer.Begin(Renderer::TriangleList); renderer.AddVertex(...); renderer.AddVertex(...); renderer.AddVertex(...); renderer.End();
type | Type of the primitives that are going to be rendered |
void sf::Renderer::Clear | ( | const Color & | color | ) |
Clear the color buffer.
color | Color to use to clear the color buffer |
void sf::Renderer::End | ( | ) |
End the current geometry batch and render it.
void sf::Renderer::Initialize | ( | ) |
Initialize the renderer (set the default states, etc.)
void sf::Renderer::PopStates | ( | ) |
Restore the previously saved render states.
void sf::Renderer::PushStates | ( | ) |
Save the current render states.
void sf::Renderer::RestoreGLStates | ( | ) |
Restore the previously saved OpenGL render states and matrices.
void sf::Renderer::SaveGLStates | ( | ) |
Save the current OpenGL render states and matrices.
void sf::Renderer::SetBlendMode | ( | Blend::Mode | mode | ) |
Set the current alpha-blending mode.
mode | New blending mode |
void sf::Renderer::SetColor | ( | const Color & | color | ) |
Set the current global color.
This color will be modulated with each vertex's color.
color | New global color |
void sf::Renderer::SetModelView | ( | const Matrix3 & | matrix | ) |
void sf::Renderer::SetProjection | ( | const Matrix3 & | matrix | ) |
Set a new projection matrix.
matrix | New projection matrix |
void sf::Renderer::SetShader | ( | const Shader * | shader | ) |
Set the current shader.
shader | New Shader |
void sf::Renderer::SetTexture | ( | const Texture * | texture | ) |
Set the current texture.
texture | New texture |
void sf::Renderer::SetViewport | ( | const IntRect & | viewport | ) |
Set the current viewport.
viewport | New viewport to apply |