sf::Renderer Class Reference
[Graphics module]

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

#include <Renderer.hpp>

Inheritance diagram for sf::Renderer:
sf::GlResource 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.
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 ()

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 48 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 56 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

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

Parameters:
color Color to modulate
See also:
SetColor
void sf::Renderer::ApplyModelView ( const Matrix3 matrix  ) 

Combine a new model-view matrix with the current one.

Parameters:
matrix Model-view matrix to combine
See also:
SetModelView
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();
Parameters:
type Type of the primitives that are going to be rendered
See also:
End
void sf::Renderer::Clear ( const Color color  ) 

Clear the color buffer.

Parameters:
color Color to use to clear the color buffer
void sf::Renderer::End (  ) 

End the current geometry batch and render it.

See also:
Begin
void sf::Renderer::Initialize (  ) 

Initialize the renderer (set the default states, etc.

)

void sf::Renderer::PopStates (  ) 

Restore the previously saved render states.

See also:
PushStates
void sf::Renderer::PushStates (  ) 

Save the current render states.

See also:
PopStates
void sf::Renderer::RestoreGLStates (  ) 

Restore the previously saved OpenGL render states and matrices.

See also:
SaveGLStates
void sf::Renderer::SaveGLStates (  ) 

Save the current OpenGL render states and matrices.

See also:
RestoreGLStates
void sf::Renderer::SetBlendMode ( Blend::Mode  mode  ) 

Set the current alpha-blending mode.

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

Parameters:
color New global color
See also:
ApplyColor
void sf::Renderer::SetModelView ( const Matrix3 matrix  ) 

Set a new model-view matrix.

Parameters:
matrix New model-view matrix
See also:
ApplyModelView
void sf::Renderer::SetProjection ( const Matrix3 matrix  ) 

Set a new projection matrix.

Parameters:
matrix New projection matrix
See also:
ApplyProjection
void sf::Renderer::SetShader ( const Shader shader  ) 

Set the current shader.

Parameters:
shader New Shader
void sf::Renderer::SetTexture ( const Texture texture  ) 

Set the current texture.

Parameters:
texture New texture
void sf::Renderer::SetViewport ( const IntRect viewport  ) 

Set the current viewport.

Parameters:
viewport New viewport to apply

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