RenderTarget

Base class for all render targets (window, texture, ...)

RenderTarget defines the common behaviour of all the 2D render targets usable in the graphics module.

It makes it possible to draw 2D entities like sprites, shapes, text without using any OpenGL command directly.

A RenderTarget is also able to use views which are a kind of 2D cameras. With views you can globally scroll, rotate or zoom everything that is drawn, without having to transform every single entity.

On top of that, render targets are still able to render direct OpenGL stuff. It is even possible to mix together OpenGL calls and regular SFML drawing commands. When doing so, make sure that OpenGL states are not messed up by calling the pushGLStates/popGLStates functions.

Members

Functions

clear
void clear(Color color)

Clear the entire target with a single color.

draw
void draw(Drawable drawable, RenderStates states)

Draw a drawable object to the render target.

draw
void draw(const(Vertex)[] vertices, PrimitiveType type, RenderStates states)

Draw primitives defined by an array of vertices.

getDefaultView
const(View) getDefaultView()

Get the default view of the render target.

getSize
Vector2u getSize()

Return the size of the rendering region of the target.

getViewport
IntRect getViewport(const(View) view)

Get the viewport of a view, applied to this render target.

mapCoordsToPixel
Vector2i mapCoordsToPixel(Vector2f point)

Convert a point from target coordinates to world coordinates, using the current view.

mapCoordsToPixel
Vector2i mapCoordsToPixel(Vector2f point, const(View) view)

Convert a point from world coordinates to target coordinates.

mapPixelToCoords
Vector2f mapPixelToCoords(Vector2i point)

Convert a point fom target coordinates to world coordinates, using the current view.

mapPixelToCoords
Vector2f mapPixelToCoords(Vector2i point, const(View) view)

Convert a point from target coordinates to world coordinates.

popGLStates
void popGLStates()

Restore the previously saved OpenGL render states and matrices.

pushGLStates
void pushGLStates()

Save the current OpenGL render states and matrices.

resetGLStates
void resetGLStates()

Reset the internal OpenGL states so that the target is ready for drawing.

Properties

view
const(View) view [@property setter]

Change the current active view.

view
const(View) view [@property getter]
Undocumented in source.

See Also

Meta

Authors

Laurent Gomila, Jeremy DeHaan