CSFML

- Main Page
- Data Structures
- Files

- File List
- Globals

Functions
RenderTexture.h File Reference
`#include <SFML/Graphics/Export.h>`
`#include <SFML/Graphics/Color.h>`
`#include <SFML/Graphics/Rect.h>`
`#include <SFML/Graphics/Types.h>`
`#include <SFML/Graphics/PrimitiveType.h>`
`#include <SFML/Graphics/RenderStates.h>`
`#include <SFML/Graphics/Vertex.h>`
`#include <SFML/System/Vector2.h>`
`#include <stddef.h>`

Go to the source code of this file.

## Functions

CSFML_GRAPHICS_API sfRenderTexture * | sfRenderTexture_create (unsigned int width, unsigned int height, sfBool depthBuffer)
| Construct a new render texture. More...
CSFML_GRAPHICS_API void | sfRenderTexture_destroy (sfRenderTexture *renderTexture)
| Destroy an existing render texture. More...
CSFML_GRAPHICS_API sfVector2u | sfRenderTexture_getSize (const sfRenderTexture *renderTexture)
| Get the size of the rendering region of a render texture. More...
CSFML_GRAPHICS_API sfBool | sfRenderTexture_setActive (sfRenderTexture *renderTexture, sfBool active)
| Activate or deactivate a render texture as the current target for rendering. More...
CSFML_GRAPHICS_API void | sfRenderTexture_display (sfRenderTexture *renderTexture)
| Update the contents of the target texture. More...
CSFML_GRAPHICS_API void | sfRenderTexture_clear (sfRenderTexture *renderTexture, sfColor color)
| Clear the rendertexture with the given color. More...
CSFML_GRAPHICS_API void | sfRenderTexture_setView (sfRenderTexture *renderTexture, const sfView *view)
| Change the current active view of a render texture. More...
CSFML_GRAPHICS_API const sfView * | sfRenderTexture_getView (const sfRenderTexture *renderTexture)
| Get the current active view of a render texture. More...
CSFML_GRAPHICS_API const sfView * | sfRenderTexture_getDefaultView (const sfRenderTexture *renderTexture)
| Get the default view of a render texture. More...
CSFML_GRAPHICS_API sfIntRect | sfRenderTexture_getViewport (const sfRenderTexture *renderTexture, const sfView *view)
| Get the viewport of a view applied to this target. More...
CSFML_GRAPHICS_API sfVector2f | sfRenderTexture_mapPixelToCoords (const sfRenderTexture *renderTexture, sfVector2i point, const sfView *view)
| Convert a point from texture coordinates to world coordinates. More...
CSFML_GRAPHICS_API sfVector2i | sfRenderTexture_mapCoordsToPixel (const sfRenderTexture *renderTexture, sfVector2f point, const sfView *view)
| Convert a point from world coordinates to texture coordinates. More...
CSFML_GRAPHICS_API void | sfRenderTexture_drawSprite (sfRenderTexture *renderTexture, const sfSprite *object, const sfRenderStates *states)
| Draw a drawable object to the render-target. More...
CSFML_GRAPHICS_API void | sfRenderTexture_drawText (sfRenderTexture *renderTexture, const sfText *object, const sfRenderStates *states)
CSFML_GRAPHICS_API void | sfRenderTexture_drawShape (sfRenderTexture *renderTexture, const sfShape *object, const sfRenderStates *states)
CSFML_GRAPHICS_API void | sfRenderTexture_drawCircleShape (sfRenderTexture *renderTexture, const sfCircleShape *object, const sfRenderStates *states)
CSFML_GRAPHICS_API void | sfRenderTexture_drawConvexShape (sfRenderTexture *renderTexture, const sfConvexShape *object, const sfRenderStates *states)
CSFML_GRAPHICS_API void | sfRenderTexture_drawRectangleShape (sfRenderTexture *renderTexture, const sfRectangleShape *object, const sfRenderStates *states)
CSFML_GRAPHICS_API void | sfRenderTexture_drawVertexArray (sfRenderTexture *renderTexture, const sfVertexArray *object, const sfRenderStates *states)
CSFML_GRAPHICS_API void | sfRenderTexture_drawPrimitives (sfRenderTexture *renderTexture, const sfVertex *vertices, size_t vertexCount, sfPrimitiveType type, const sfRenderStates *states)
| Draw primitives defined by an array of vertices to a render texture. More...
CSFML_GRAPHICS_API void | sfRenderTexture_pushGLStates (sfRenderTexture *renderTexture)
| Save the current OpenGL render states and matrices. More...
CSFML_GRAPHICS_API void | sfRenderTexture_popGLStates (sfRenderTexture *renderTexture)
| Restore the previously saved OpenGL render states and matrices. More...
CSFML_GRAPHICS_API void | sfRenderTexture_resetGLStates (sfRenderTexture *renderTexture)
| Reset the internal OpenGL states so that the target is ready for drawing. More...
CSFML_GRAPHICS_API const sfTexture * | sfRenderTexture_getTexture (const sfRenderTexture *renderTexture)
| Get the target texture of a render texture. More...
CSFML_GRAPHICS_API void | sfRenderTexture_setSmooth (sfRenderTexture *renderTexture, sfBool smooth)
| Enable or disable the smooth filter on a render texture. More...
CSFML_GRAPHICS_API sfBool | sfRenderTexture_isSmooth (const sfRenderTexture *renderTexture)
| Tell whether the smooth filter is enabled or not for a render texture. More...
CSFML_GRAPHICS_API void | sfRenderTexture_setRepeated (sfRenderTexture *renderTexture, sfBool repeated)
| Enable or disable texture repeating. More...
CSFML_GRAPHICS_API sfBool | sfRenderTexture_isRepeated (const sfRenderTexture *renderTexture)
| Tell whether the texture is repeated or not. More...

## Function Documentation

CSFML_GRAPHICS_API void sfRenderTexture_clear | ( | sfRenderTexture * | renderTexture,
|  | sfColor | color
| ) |  |

Clear the rendertexture with the given color.

Parameters

  renderTexture | Render texture object
  color | Fill color

CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_create | ( | unsigned int | width,
|  | unsigned int | height,
|  | sfBool | depthBuffer
| ) |  |

Construct a new render texture.

Parameters

  width | Width of the render texture
  height | Height of the render texture
  depthBuffer | Do you want a depth-buffer attached? (useful only if you're doing 3D OpenGL on the rendertexture)

Returns
  A new sfRenderTexture object, or NULL if it failed

CSFML_GRAPHICS_API void sfRenderTexture_destroy | ( | sfRenderTexture * | renderTexture | ) |

Destroy an existing render texture.

Parameters

  renderTexture | Render texture to destroy

CSFML_GRAPHICS_API void sfRenderTexture_display | ( | sfRenderTexture * | renderTexture | ) |

Update the contents of the target texture.

Parameters

  renderTexture | Render texture object

CSFML_GRAPHICS_API void sfRenderTexture_drawCircleShape | ( | sfRenderTexture * | renderTexture,
|  | const sfCircleShape * | object,
|  | const sfRenderStates * | states
| ) |  |

CSFML_GRAPHICS_API void sfRenderTexture_drawConvexShape | ( | sfRenderTexture * | renderTexture,
|  | const sfConvexShape * | object,
|  | const sfRenderStates * | states
| ) |  |

CSFML_GRAPHICS_API void sfRenderTexture_drawPrimitives | ( | sfRenderTexture * | renderTexture,
|  | const sfVertex * | vertices,
|  | size_t | vertexCount,
|  | sfPrimitiveType | type,
|  | const sfRenderStates * | states
| ) |  |

Draw primitives defined by an array of vertices to a render texture.

Parameters

  renderTexture | Render texture object
  vertices | Pointer to the vertices
  vertexCount | Number of vertices in the array
  type | Type of primitives to draw
  states | Render states to use for drawing (NULL to use the default states)

CSFML_GRAPHICS_API void sfRenderTexture_drawRectangleShape | ( | sfRenderTexture * | renderTexture,
|  | const sfRectangleShape * | object,
|  | const sfRenderStates * | states
| ) |  |

CSFML_GRAPHICS_API void sfRenderTexture_drawShape | ( | sfRenderTexture * | renderTexture,
|  | const sfShape * | object,
|  | const sfRenderStates * | states
| ) |  |

CSFML_GRAPHICS_API void sfRenderTexture_drawSprite | ( | sfRenderTexture * | renderTexture,
|  | const sfSprite * | object,
|  | const sfRenderStates * | states
| ) |  |

Draw a drawable object to the render-target.

Parameters

  renderTexture | Render texture object
  object | Object to draw
  states | Render states to use for drawing (NULL to use the default states)

CSFML_GRAPHICS_API void sfRenderTexture_drawText | ( | sfRenderTexture * | renderTexture,
|  | const sfText * | object,
|  | const sfRenderStates * | states
| ) |  |

CSFML_GRAPHICS_API void sfRenderTexture_drawVertexArray | ( | sfRenderTexture * | renderTexture,
|  | const sfVertexArray * | object,
|  | const sfRenderStates * | states
| ) |  |

CSFML_GRAPHICS_API const sfView* sfRenderTexture_getDefaultView | ( | const sfRenderTexture * | renderTexture | ) |

Get the default view of a render texture.

Parameters

  renderTexture | Render texture object

Returns
  Default view of the rendertexture

CSFML_GRAPHICS_API sfVector2u sfRenderTexture_getSize | ( | const sfRenderTexture * | renderTexture | ) |

Get the size of the rendering region of a render texture.

Parameters

  renderTexture | Render texture object

Returns
  Size in pixels

CSFML_GRAPHICS_API const sfTexture* sfRenderTexture_getTexture | ( | const sfRenderTexture * | renderTexture | ) |

Get the target texture of a render texture.

Parameters

  renderTexture | Render texture object

Returns
  Pointer to the target texture

CSFML_GRAPHICS_API const sfView* sfRenderTexture_getView | ( | const sfRenderTexture * | renderTexture | ) |

Get the current active view of a render texture.

Parameters

  renderTexture | Render texture object

Returns
  Current active view

CSFML_GRAPHICS_API sfIntRect sfRenderTexture_getViewport | ( | const sfRenderTexture * | renderTexture,
|  | const sfView * | view
| ) |  |

Get the viewport of a view applied to this target.

Parameters

  renderTexture | Render texture object
  view | Target view

Returns
  Viewport rectangle, expressed in pixels in the current target

CSFML_GRAPHICS_API sfBool sfRenderTexture_isRepeated | ( | const sfRenderTexture * | renderTexture | ) |

Tell whether the texture is repeated or not.

Parameters

  renderTexture | Render texture object

Returns
  sfTrue if repeat mode is enabled, sfFalse if it is disabled

CSFML_GRAPHICS_API sfBool sfRenderTexture_isSmooth | ( | const sfRenderTexture * | renderTexture | ) |

Tell whether the smooth filter is enabled or not for a render texture.

Parameters

  renderTexture | Render texture object

Returns
  sfTrue if smoothing is enabled, sfFalse if it is disabled

CSFML_GRAPHICS_API sfVector2i sfRenderTexture_mapCoordsToPixel | ( | const sfRenderTexture * | renderTexture,
|  | sfVector2f | point,
|  | const sfView * | view
| ) |  |

Convert a point from world coordinates to texture coordinates.

This function finds the pixel of the render-texture that matches the given 2D point. In other words, it goes through the same process as the graphics card, to compute the final position of a rendered point.

Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-texture, this assertion is not true anymore, ie. a point located at (150, 75) in your 2D world may map to the pixel (10, 50) of your render-texture – if the view is translated by (140, 25).

This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-texture.

Parameters

  renderTexture | Render texture object
  point | Point to convert
  view | The view to use for converting the point

Returns
  The converted point, in target coordinates (pixels)

CSFML_GRAPHICS_API sfVector2f sfRenderTexture_mapPixelToCoords | ( | const sfRenderTexture * | renderTexture,
|  | sfVector2i | point,
|  | const sfView * | view
| ) |  |

Convert a point from texture coordinates to world coordinates.

This function finds the 2D position that matches the given pixel of the render-texture. In other words, it does the inverse of what the graphics card does, to find the initial position of a rendered pixel.

Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-texture, this assertion is not true anymore, ie. a point located at (10, 50) in your render-texture may map to the point (150, 75) in your 2D world – if the view is translated by (140, 25).

This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-texture.

Parameters

  renderTexture | Render texture object
  point | Pixel to convert
  view | The view to use for converting the point

Returns
  The converted point, in "world" units

CSFML_GRAPHICS_API void sfRenderTexture_popGLStates | ( | sfRenderTexture * | renderTexture | ) |

Restore the previously saved OpenGL render states and matrices.

See the description of pushGLStates to get a detailed description of these functions.

Parameters

  renderTexture | Render texture object

CSFML_GRAPHICS_API void sfRenderTexture_pushGLStates | ( | sfRenderTexture * | renderTexture | ) |

Save the current OpenGL render states and matrices.

This function can be used when you mix SFML drawing and direct OpenGL rendering. Combined with popGLStates, it ensures that:

- SFML's internal states are not messed up by your OpenGL code
- your OpenGL states are not modified by a call to a SFML function

Note that this function is quite expensive: it saves all the possible OpenGL states and matrices, even the ones you don't care about. Therefore it should be used wisely. It is provided for convenience, but the best results will be achieved if you handle OpenGL states yourself (because you know which states have really changed, and need to be saved and restored). Take a look at the resetGLStates function if you do so.

Parameters

  renderTexture | Render texture object

CSFML_GRAPHICS_API void sfRenderTexture_resetGLStates | ( | sfRenderTexture * | renderTexture | ) |

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

This function can be used when you mix SFML drawing and direct OpenGL rendering, if you choose not to use pushGLStates/popGLStates. It makes sure that all OpenGL states needed by SFML are set, so that subsequent sfRenderTexture_draw*() calls will work as expected.

Parameters

  renderTexture | Render texture object

CSFML_GRAPHICS_API sfBool sfRenderTexture_setActive | ( | sfRenderTexture * | renderTexture,
|  | sfBool | active
| ) |  |

Activate or deactivate a render texture as the current target for rendering.

Parameters

  renderTexture | Render texture object
  active | sfTrue to activate, sfFalse to deactivate

Returns
  True if operation was successful, false otherwise

CSFML_GRAPHICS_API void sfRenderTexture_setRepeated | ( | sfRenderTexture * | renderTexture,
|  | sfBool | repeated
| ) |  |

Enable or disable texture repeating.

Parameters

  renderTexture | Render texture object
  repeated | sfTrue to enable repeating, sfFalse to disable it

CSFML_GRAPHICS_API void sfRenderTexture_setSmooth | ( | sfRenderTexture * | renderTexture,
|  | sfBool | smooth
| ) |  |

Enable or disable the smooth filter on a render texture.

Parameters

  renderTexture | Render texture object
  smooth | sfTrue to enable smoothing, sfFalse to disable it

CSFML_GRAPHICS_API void sfRenderTexture_setView | ( | sfRenderTexture * | renderTexture,
|  | const sfView * | view
| ) |  |

Change the current active view of a render texture.

Parameters

  renderTexture | Render texture object
  view | Pointer to the new view