sf::Renderer Class Reference

Handles the low-level rendering (states and geometry). More...

#include <Renderer.hpp>

Inheritance diagram for sf::Renderer:
sf::NonCopyable

List of all members.

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).

Detailed Description

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.


Member Enumeration Documentation

Types of primitives to be rendererd.

Enumerator:
TriangleList 

Simple list of triangles.

TriangleStrip 

Triangle strip (consecutive triangles always share two points).

TriangleFan 

Triangle fan (one center point + outline points).

QuadList 

Simple list of quads.

Definition at line 55 of file Renderer.hpp.


Constructor & Destructor Documentation

sf::Renderer::Renderer ( RenderTarget target  ) 

Construct the renderer with its owner render target.

Parameters:
target Owner render target

Definition at line 38 of file Renderer.cpp.

sf::Renderer::~Renderer (  ) 

Destructor.

Definition at line 50 of file Renderer.cpp.


Member Function Documentation

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.

Parameters:
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).

Parameters:
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).

Parameters:
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).

Parameters:
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.

Parameters:
color Color to modulate
See also:
SetColor

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.

Parameters:
matrix Model-view matrix to combine
See also:
SetModelView

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();

See also:
End

Definition at line 288 of file Renderer.cpp.

void sf::Renderer::Clear ( const Color color  ) 

Clear the color buffer.

Parameters:
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.

See also:
Begin

Definition at line 303 of file Renderer.cpp.

void sf::Renderer::Initialize (  ) 

Initialize the renderer (set the default states, etc.

)

Definition at line 56 of file Renderer.cpp.

void sf::Renderer::PopStates (  ) 

Restore the previously saved render states.

See also:
PushStates

Definition at line 124 of file Renderer.cpp.

void sf::Renderer::PushStates (  ) 

Save the current render states.

See also:
PopStates

Definition at line 116 of file Renderer.cpp.

void sf::Renderer::RestoreGLStates (  ) 

Restore the previously saved OpenGL render states and matrices.

See also:
SaveGLStates

Definition at line 94 of file Renderer.cpp.

void sf::Renderer::SaveGLStates (  ) 

Save the current OpenGL render states and matrices.

See also:
RestoreGLStates

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.

Parameters:
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.

Parameters:
color New global color
See also:
ApplyColor

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.

Parameters:
matrix New model-view matrix
See also:
ApplyModelView

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.

Parameters:
matrix New projection matrix
See also:
ApplyProjection

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.

Parameters:
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.

Parameters:
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.

Parameters:
viewport New viewport to apply

Definition at line 174 of file Renderer.cpp.


The documentation for this class was generated from the following files: