RenderTexture

Target for off-screen 2D rendering into a texture.

RenderTexture is the little brother of RenderWindow.

It implements the same 2D drawing and OpenGL-related functions (see their base class RenderTarget for more details), the difference is that the result is stored in an off-screen texture rather than being show in a window.

Rendering to a texture can be useful in a variety of situations: - precomputing a complex static texture (like a level's background from multiple tiles) - applying post-effects to the whole scene with shaders - creating a sprite from a 3D object rendered with OpenGL - etc.

Constructors

this
this()
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Members

Functions

clear
void clear(Color color)

Clear the entire target with a single color.

create
void create(uint width, uint height, bool depthBuffer)

Create the render-texture.

display
void display()

Update the contents of the target texture.

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.

getTexture
const(Texture) getTexture()

Get a read-only reference to the target texture.

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.

setActive
void setActive(bool active)

Activate or deactivate the render-texture for rendering.

Properties

smooth
bool smooth [@property setter]

Enable or disable texture smoothing.

smooth
bool smooth [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
view
const(View) view [@property setter]

Change the current active view.

view
const(View) view [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

sfPtr
sfRenderTexture* sfPtr;
Undocumented in source.

Inherited Members

From RenderTarget

view
const(View) view [@property setter]

Change the current active view.

view
const(View) view [@property getter]
Undocumented in source.
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.

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.

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.

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.

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.

See Also

Meta

Authors

Laurent Gomila, Jeremy DeHaan