Gamedev Framework (gf)  0.3.0
A C++11 framework for 2D games
Classes | Public Member Functions | Protected Member Functions | List of all members
gf::RenderPipeline Class Reference

A render pipeline. More...

#include <gf/RenderPipeline.h>

Inheritance diagram for gf::RenderPipeline:
Inheritance graph
[legend]

Public Member Functions

 RenderPipeline (Window &window)
 Constructor. More...
 
 ~RenderPipeline ()
 Destructor. More...
 
void addEffect (Effect &effect)
 Add an effect to the pipeline. More...
 
void clearEffects ()
 Clear the pipeline. More...
 
void resized ()
 Update the size of the target. More...
 
virtual Vector2u getSize () const override
 Return the size of the rendering region of the target. More...
 
void display ()
 Apply the effects and display what has been rendered. More...
 
- Public Member Functions inherited from gf::RenderTarget
 RenderTarget ()=default
 Default constructor. More...
 
virtual ~RenderTarget ()
 Destructor. More...
 
 RenderTarget (const RenderTarget &)=delete
 Deleted copy constructor. More...
 
RenderTargetoperator= (const RenderTarget &)=delete
 Deleted copy assignment. More...
 
bool getScissorTest ()
 Tell if the scissor test is enabled. More...
 
void setScissorTest (bool scissor=true)
 Enable or disable the scissor test. More...
 
RectI getScissoBox ()
 Get the current scissor box. More...
 
void setScissorBox (const RectI &box)
 Define the scissor box. More...
 
void clear (const Color4f &color)
 Clear the entire target with a single color. More...
 
void clear ()
 Clear the entire target. More...
 
RangeF getAliasedLineWidthRange () const
 Get the range for aliased line width. More...
 
float getLineWidth () const
 Get the line width. More...
 
void draw (const Vertex *vertices, std::size_t count, PrimitiveType type, const RenderStates &states=RenderStates())
 Draw primitives defined by an array of vertices. More...
 
void draw (const Vertex *vertices, const uint16_t *indices, std::size_t count, PrimitiveType type, const RenderStates &states=RenderStates())
 Draw primitives defined by an array of vertices and their indices. More...
 
void draw (const Vertex *vertices, int *first, const std::size_t *count, std::size_t primcount, PrimitiveType type, const RenderStates &states=RenderStates())
 Draw primitives defined by an array of vertices. More...
 
void draw (const Vertex *vertices, const uint16_t **indices, const std::size_t *count, std::size_t primcount, PrimitiveType type, const RenderStates &states=RenderStates())
 Draw primitives defined by an array of vertices and their indices. More...
 
void draw (const VertexBuffer &buffer, const RenderStates &states=RenderStates())
 Draw a vertex buffer to the render target. More...
 
void draw (Drawable &drawable, const RenderStates &states=RenderStates())
 Draw a drawable object to the render target. More...
 
void setView (const View &view)
 Change the current active view. More...
 
const ViewgetView () const
 Get the view currently in use in the render target. More...
 
RectI getViewport (const View &view) const
 Get the viewport of a view, applied to this render target. More...
 
Vector2f mapPixelToCoords (Vector2i point, const View &view) const
 Convert a point from target coordinates to world coordinates. More...
 
Vector2f mapPixelToCoords (Vector2i point) const
 Convert a point from target coordinates to world coordinates, using the current view. More...
 
Vector2i mapCoordsToPixel (Vector2f point, const View &view) const
 Convert a point from world coordinates to target coordinates. More...
 
Vector2i mapCoordsToPixel (Vector2f point) const
 Convert a point from world coordinates to target coordinates, using the current view. More...
 

Protected Member Functions

virtual void onFramebufferResize (Vector2u size)
 Callback when the screen has just been resized. More...
 
- Protected Member Functions inherited from gf::RenderTarget
void initialize ()
 Performs the common initialization step after creation. More...
 
Image captureFramebuffer (unsigned name) const
 Capture the given framebuffer. More...
 

Detailed Description

A render pipeline.

A render pipeline automates the application of post-processing effects. A good way to use this class is to make a subclass with all the effects you want to add.

class MyPipeline : public gf::RenderPipeline {
public:
MyPipeline(gf::Window& window)
: gf::RenderPipeline(window)
{
addEffect(m_effect);
addEffect(m_other);
}
protected:
virtual void onFramebufferResize(Vector2u size) override {
// update effects with size
}
private:
MyEffect m_effect;
MyOtherEffect m_other;
};
See also
gf::Effect

Constructor & Destructor Documentation

gf::RenderPipeline::RenderPipeline ( Window window)

Constructor.

Parameters
windowThe window to render to
gf::RenderPipeline::~RenderPipeline ( )

Destructor.

Member Function Documentation

void gf::RenderPipeline::addEffect ( Effect effect)

Add an effect to the pipeline.

Parameters
effectThe effect
void gf::RenderPipeline::clearEffects ( )

Clear the pipeline.

void gf::RenderPipeline::display ( )

Apply the effects and display what has been rendered.

virtual Vector2u gf::RenderPipeline::getSize ( ) const
overridevirtual

Return the size of the rendering region of the target.

Returns
Size in pixels

Implements gf::RenderTarget.

virtual void gf::RenderPipeline::onFramebufferResize ( Vector2u  size)
protectedvirtual

Callback when the screen has just been resized.

This function is called by resized() with the correct size.

Parameters
sizeThe new framebuffer size
void gf::RenderPipeline::resized ( )

Update the size of the target.

This function must be called when the window change its size, before anything is drawn on the target. You can do it in the event processing.

gf::Event event;
// ...
switch (event.type) {
renderer.resized();
break;
// ...
}