|
| | RenderTexture () |
| | Default constructor.
|
| | RenderTexture (Vector2u size, const ContextSettings &settings={}) |
| | Construct a render-texture.
|
| | ~RenderTexture () override |
| | Destructor.
|
| | RenderTexture (const RenderTexture &)=delete |
| | Deleted copy constructor.
|
| RenderTexture & | operator= (const RenderTexture &)=delete |
| | Deleted copy assignment.
|
| | RenderTexture (RenderTexture &&) noexcept |
| | Move constructor.
|
| RenderTexture & | operator= (RenderTexture &&) noexcept |
| | Move assignment operator.
|
| bool | resize (Vector2u size, const ContextSettings &settings={}) |
| | Resize the render-texture.
|
| void | setSmooth (bool smooth) |
| | Enable or disable texture smoothing.
|
| bool | isSmooth () const |
| | Tell whether the smooth filtering is enabled or not.
|
| void | setRepeated (bool repeated) |
| | Enable or disable texture repeating.
|
| bool | isRepeated () const |
| | Tell whether the texture is repeated or not.
|
| bool | generateMipmap () |
| | Generate a mipmap using the current texture data.
|
| bool | setActive (bool active=true) override |
| | Activate or deactivate the render-texture for rendering.
|
| void | display () |
| | Update the contents of the target texture.
|
| Vector2u | getSize () const override |
| | Return the size of the rendering region of the texture.
|
| bool | isSrgb () const override |
| | Tell if the render-texture will use sRGB encoding when drawing on it.
|
| const Texture & | getTexture () const |
| | Get a read-only reference to the target texture.
|
| virtual | ~RenderTarget ()=default |
| | Destructor.
|
| | RenderTarget (const RenderTarget &)=delete |
| | Deleted copy constructor.
|
| RenderTarget & | operator= (const RenderTarget &)=delete |
| | Deleted copy assignment.
|
| | RenderTarget (RenderTarget &&) noexcept=default |
| | Move constructor.
|
| RenderTarget & | operator= (RenderTarget &&) noexcept=default |
| | Move assignment.
|
| void | clear (Color color=Color::Black) |
| | Clear the entire target with a single color.
|
| void | clearStencil (StencilValue stencilValue) |
| | Clear the stencil buffer to a specific value.
|
| void | clear (Color color, StencilValue stencilValue) |
| | Clear the entire target with a single color and stencil value.
|
| void | setView (const View &view) |
| | Change the current active view.
|
| const View & | getView () const |
| | Get the view currently in use in the render target.
|
| const View & | getDefaultView () const |
| | Get the default view of the render target.
|
| IntRect | getViewport (const View &view) const |
| | Get the viewport of a view, applied to this render target.
|
| IntRect | getScissor (const View &view) const |
| | Get the scissor rectangle of a view, applied to this render target.
|
| Vector2f | mapPixelToCoords (Vector2i point) const |
| | Convert a point from target coordinates to world coordinates, using the current view.
|
| Vector2f | mapPixelToCoords (Vector2i point, const View &view) const |
| | Convert a point from target coordinates to world coordinates.
|
| Vector2i | mapCoordsToPixel (Vector2f point) const |
| | Convert a point from world coordinates to target coordinates, using the current view.
|
| Vector2i | mapCoordsToPixel (Vector2f point, const View &view) const |
| | Convert a point from world coordinates to target coordinates.
|
| void | draw (const Drawable &drawable, const RenderStates &states=RenderStates::Default) |
| | Draw a drawable object to the render target.
|
| void | draw (const Vertex *vertices, std::size_t vertexCount, PrimitiveType type, const RenderStates &states=RenderStates::Default) |
| | Draw primitives defined by an array of vertices.
|
| void | draw (const VertexBuffer &vertexBuffer, const RenderStates &states=RenderStates::Default) |
| | Draw primitives defined by a vertex buffer.
|
| void | draw (const VertexBuffer &vertexBuffer, std::size_t firstVertex, std::size_t vertexCount, const RenderStates &states=RenderStates::Default) |
| | Draw primitives defined by a vertex buffer.
|
| void | pushGLStates () |
| | Save the current OpenGL render states and matrices.
|
| void | popGLStates () |
| | Restore the previously saved OpenGL render states and matrices.
|
| void | resetGLStates () |
| | Reset the internal OpenGL states so that the target is ready for drawing.
|
Target for off-screen 2D rendering into a texture.
sf::RenderTexture is the little brother of sf::RenderWindow. It implements the same 2D drawing and OpenGL-related functions (see their base class sf::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.
Usage example:
{
texture.draw(sprite);
texture.draw(shape);
texture.draw(text);
texture.display();
}
static const Color Red
Red predefined color.
Definition Color.hpp:84
void draw(const Drawable &drawable, const RenderStates &states=RenderStates::Default)
Draw a drawable object to the render target.
void clear(Color color=Color::Black)
Clear the entire target with a single color.
Target for off-screen 2D rendering into a texture.
Definition RenderTexture.hpp:54
Window that can serve as a target for 2D drawing.
Definition RenderWindow.hpp:55
Drawable representation of a texture, with its own transformations, color, etc.
Definition Sprite.hpp:51
VideoMode defines a video mode (width, height, bpp).
Definition VideoMode.hpp:44
bool isOpen() const
Tell whether or not the window is open.
void display()
Display on screen what has been rendered to the window so far.
Like sf::RenderWindow, sf::RenderTexture is still able to render direct OpenGL stuff. It is even possible to mix together OpenGL calls and regular SFML drawing commands. If you need a depth buffer for 3D rendering, don't forget to request it when calling RenderTexture::create.
- See also
- sf::RenderTarget, sf::RenderWindow, sf::View, sf::Texture