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. | |
~Renderer () | |
Destructor. | |
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 Image *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). |
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 47 of file Renderer.hpp.
Types of primitives to be rendererd.
Definition at line 55 of file Renderer.hpp.
sf::Renderer::Renderer | ( | RenderTarget & | target | ) |
Construct the renderer with its owner render target.
target | Owner render target |
Definition at line 38 of file Renderer.cpp.
sf::Renderer::~Renderer | ( | ) |
Destructor.
Definition at line 50 of file Renderer.cpp.
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 |
Definition at line 332 of file Renderer.cpp.
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 |
Definition at line 325 of file Renderer.cpp.
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 |
Definition at line 318 of file Renderer.cpp.
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 |
Definition at line 311 of file Renderer.cpp.
void sf::Renderer::ApplyColor | ( | const Color & | color | ) |
Modulate the current global color with a new one.
This color will be modulated with each vertex's color. Note: any call to this function after a call to BeginBatch will be ignored, and delayed until BeginBatch is called again.
color | Color to modulate |
Definition at line 164 of file Renderer.cpp.
void sf::Renderer::ApplyModelView | ( | const Matrix3 & | matrix | ) |
Combine a new model-view matrix with the current one.
Note: any call to this function after a call to BeginBatch will be ignored, and delayed until BeginBatch is called again.
matrix | Model-view matrix to combine |
Definition at line 138 of file Renderer.cpp.
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();
Definition at line 288 of file Renderer.cpp.
void sf::Renderer::Clear | ( | const Color & | color | ) |
Clear the color buffer.
color | Color to use to clear the color buffer |
Definition at line 108 of file Renderer.cpp.
void sf::Renderer::End | ( | ) |
End the current geometry batch and render it.
Definition at line 303 of file Renderer.cpp.
void sf::Renderer::Initialize | ( | ) |
void sf::Renderer::PopStates | ( | ) |
Restore the previously saved render states.
Definition at line 124 of file Renderer.cpp.
void sf::Renderer::PushStates | ( | ) |
void sf::Renderer::RestoreGLStates | ( | ) |
Restore the previously saved OpenGL render states and matrices.
Definition at line 94 of file Renderer.cpp.
void sf::Renderer::SaveGLStates | ( | ) |
Save the current OpenGL render states and matrices.
Definition at line 80 of file Renderer.cpp.
void sf::Renderer::SetBlendMode | ( | Blend::Mode | mode | ) |
Set the current alpha-blending mode.
Note: any call to this function after a call to BeginBatch will be ignored, and delayed until BeginBatch is called again.
mode | New blending mode |
Definition at line 191 of file Renderer.cpp.
void sf::Renderer::SetColor | ( | const Color & | color | ) |
Set the current global color.
This color will be modulated with each vertex's color. Note: any call to this function after a call to BeginBatch will be ignored, and delayed until BeginBatch is called again.
color | New global color |
Definition at line 154 of file Renderer.cpp.
void sf::Renderer::SetModelView | ( | const Matrix3 & | matrix | ) |
Set a new model-view matrix.
Note: any call to this function after a call to BeginBatch will be ignored, and delayed until BeginBatch is called again.
matrix | New model-view matrix |
Definition at line 131 of file Renderer.cpp.
void sf::Renderer::SetProjection | ( | const Matrix3 & | matrix | ) |
Set a new projection matrix.
Note: any call to this function after a call to BeginBatch will be ignored, and delayed until BeginBatch is called again.
matrix | New projection matrix |
Definition at line 145 of file Renderer.cpp.
void sf::Renderer::SetShader | ( | const Shader * | shader | ) |
Set the current shader.
Note: any call to this function after a call to BeginBatch will be ignored, and delayed until BeginBatch is called again.
shader | New Shader |
Definition at line 261 of file Renderer.cpp.
void sf::Renderer::SetTexture | ( | const Image * | texture | ) |
Set the current texture.
Note: any call to this function after a call to BeginBatch will be ignored, and delayed until BeginBatch is called again.
texture | New texture |
Definition at line 237 of file Renderer.cpp.
void sf::Renderer::SetViewport | ( | const IntRect & | viewport | ) |
Set the current viewport.
Note: any call to this function after a call to BeginBatch will be ignored, and delayed until BeginBatch is called again.
viewport | New viewport to apply |
Definition at line 174 of file Renderer.cpp.