CSFML 3.0.0
Loading...
Searching...
No Matches
Functions
RenderTexture.h File Reference
`#include <CSFML/Graphics/Export.h>`
`#include <CSFML/Graphics/Color.h>`
`#include <CSFML/Graphics/PrimitiveType.h>`
`#include <CSFML/Graphics/Rect.h>`
`#include <CSFML/Graphics/RenderStates.h>`
`#include <CSFML/Graphics/StencilMode.h>`
`#include <CSFML/Graphics/Types.h>`
`#include <CSFML/Graphics/Vertex.h>`
`#include <CSFML/System/Vector2.h>`
`#include <CSFML/Window/Window.h>`
`#include <stddef.h>`

Go to the source code of this file.

## Functions
sfRenderTexture * | sfRenderTexture_create (sfVector2u size, const sfContextSettings *settings)
| Construct a new render texture.
void | sfRenderTexture_destroy (const sfRenderTexture *renderTexture)
| Destroy an existing render texture.
sfVector2u | sfRenderTexture_getSize (const sfRenderTexture *renderTexture)
| Get the size of the rendering region of a render texture.
bool | sfRenderTexture_isSrgb (const sfRenderTexture *renderTexture)
| Tell if the render texture will use sRGB encoding when drawing on it.
bool | sfRenderTexture_setActive (sfRenderTexture *renderTexture, bool active)
| Activate or deactivate a render texture as the current target for rendering.
void | sfRenderTexture_display (sfRenderTexture *renderTexture)
| Update the contents of the target texture.
void | sfRenderTexture_clear (sfRenderTexture *renderTexture, sfColor color)
| Clear the rendertexture with the given color.
void | sfRenderTexture_clearStencil (sfRenderTexture *renderTexture, sfStencilValue stencilValue)
| Clear the stencil buffer to a specific value.
void | sfRenderTexture_clearColorAndStencil (sfRenderTexture *renderTexture, sfColor color, sfStencilValue stencilValue)
| Clear the entire target with a single color and stencil value.
void | sfRenderTexture_setView (sfRenderTexture *renderTexture, const sfView *view)
| Change the current active view of a render texture.
const sfView * | sfRenderTexture_getView (const sfRenderTexture *renderTexture)
| Get the current active view of a render texture.
const sfView * | sfRenderTexture_getDefaultView (const sfRenderTexture *renderTexture)
| Get the default view of a render texture.
sfIntRect | sfRenderTexture_getViewport (const sfRenderTexture *renderTexture, const sfView *view)
| Get the viewport of a view applied to this target.
sfIntRect | sfRenderTexture_getScissor (const sfRenderTexture *renderTexture, const sfView *view)
| Get the scissor rectangle of a view, applied to this render target.
sfVector2f | sfRenderTexture_mapPixelToCoords (const sfRenderTexture *renderTexture, sfVector2i point, const sfView *view)
| Convert a point from texture coordinates to world coordinates.
sfVector2i | sfRenderTexture_mapCoordsToPixel (const sfRenderTexture *renderTexture, sfVector2f point, const sfView *view)
| Convert a point from world coordinates to texture coordinates.
void | sfRenderTexture_drawSprite (sfRenderTexture *renderTexture, const sfSprite *object, const sfRenderStates *states)
| Draw a drawable object to the render-target.
void | sfRenderTexture_drawText (sfRenderTexture *renderTexture, const sfText *object, const sfRenderStates *states)
void | sfRenderTexture_drawShape (sfRenderTexture *renderTexture, const sfShape *object, const sfRenderStates *states)
void | sfRenderTexture_drawCircleShape (sfRenderTexture *renderTexture, const sfCircleShape *object, const sfRenderStates *states)
void | sfRenderTexture_drawConvexShape (sfRenderTexture *renderTexture, const sfConvexShape *object, const sfRenderStates *states)
void | sfRenderTexture_drawRectangleShape (sfRenderTexture *renderTexture, const sfRectangleShape *object, const sfRenderStates *states)
void | sfRenderTexture_drawVertexArray (sfRenderTexture *renderTexture, const sfVertexArray *object, const sfRenderStates *states)
void | sfRenderTexture_drawVertexBuffer (sfRenderTexture *renderTexture, const sfVertexBuffer *object, const sfRenderStates *states)
void | sfRenderTexture_drawVertexBufferRange (sfRenderTexture *renderTexture, const sfVertexBuffer *object, size_t firstVertex, size_t vertexCount, const sfRenderStates *states)
| Draw primitives defined by a vertex buffer.
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.
void | sfRenderTexture_pushGLStates (sfRenderTexture *renderTexture)
| Save the current OpenGL render states and matrices.
void | sfRenderTexture_popGLStates (sfRenderTexture *renderTexture)
| Restore the previously saved OpenGL render states and matrices.
void | sfRenderTexture_resetGLStates (sfRenderTexture *renderTexture)
| Reset the internal OpenGL states so that the target is ready for drawing.
const sfTexture * | sfRenderTexture_getTexture (const sfRenderTexture *renderTexture)
| Get the target texture of a render texture.
unsigned int | sfRenderTexture_getMaximumAntiAliasingLevel (void)
| Get the maximum anti-aliasing level supported by the system.
void | sfRenderTexture_setSmooth (sfRenderTexture *renderTexture, bool smooth)
| Enable or disable the smooth filter on a render texture.
bool | sfRenderTexture_isSmooth (const sfRenderTexture *renderTexture)
| Tell whether the smooth filter is enabled or not for a render texture.
void | sfRenderTexture_setRepeated (sfRenderTexture *renderTexture, bool repeated)
| Enable or disable texture repeating.
bool | sfRenderTexture_isRepeated (const sfRenderTexture *renderTexture)
| Tell whether the texture is repeated or not.
bool | sfRenderTexture_generateMipmap (sfRenderTexture *renderTexture)
| Generate a mipmap using the current texture data.

## Function Documentation

## ◆ sfRenderTexture_clear()

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

Clear the rendertexture with the given color.

Parameters

  renderTexture | Render texture object
  color | Fill color

## ◆ sfRenderTexture_clearColorAndStencil()

void sfRenderTexture_clearColorAndStencil | ( | sfRenderTexture * | renderTexture,
|  | sfColor | color,
|  | sfStencilValue | stencilValue )

Clear the entire target with a single color and stencil value.

The specified stencil value is truncated to the bit width of the current stencil buffer.

Parameters

  renderTexture | Render texture object
  color | Fill color to use to clear the render target
  stencilValue | Stencil value to clear to

## ◆ sfRenderTexture_clearStencil()

void sfRenderTexture_clearStencil | ( | sfRenderTexture * | renderTexture,
|  | sfStencilValue | stencilValue )

Clear the stencil buffer to a specific value.

The specified value is truncated to the bit width of the current stencil buffer.

Parameters

  renderTexture | Render texture object
  stencilValue | Stencil value to clear to

## ◆ sfRenderTexture_create()

sfRenderTexture * sfRenderTexture_create | ( | sfVector2u | size,
|  | const sfContextSettings * | settings )

Construct a new render texture.

Parameters

  size | Size of the render texture
  settings | Settings of the render texture

Returns
  A new sfRenderTexture object, or NULL if it failed

## ◆ sfRenderTexture_destroy()

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

Destroy an existing render texture.

Parameters

  renderTexture | Render texture to destroy

## ◆ sfRenderTexture_display()

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

Update the contents of the target texture.

Parameters

  renderTexture | Render texture object

## ◆ sfRenderTexture_drawCircleShape()

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

## ◆ sfRenderTexture_drawConvexShape()

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

## ◆ sfRenderTexture_drawPrimitives()

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)

## ◆ sfRenderTexture_drawRectangleShape()

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

## ◆ sfRenderTexture_drawShape()

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

## ◆ sfRenderTexture_drawSprite()

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)

## ◆ sfRenderTexture_drawText()

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

## ◆ sfRenderTexture_drawVertexArray()

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

## ◆ sfRenderTexture_drawVertexBuffer()

void sfRenderTexture_drawVertexBuffer | ( | sfRenderTexture * | renderTexture,
|  | const sfVertexBuffer * | object,
|  | const sfRenderStates * | states )

## ◆ sfRenderTexture_drawVertexBufferRange()

void sfRenderTexture_drawVertexBufferRange | ( | sfRenderTexture * | renderTexture,
|  | const sfVertexBuffer * | object,
|  | size_t | firstVertex,
|  | size_t | vertexCount,
|  | const sfRenderStates * | states )

Draw primitives defined by a vertex buffer.

Parameters

  renderTexture | render texture object
  object | Vertex buffer object to draw
  firstVertex | Index of the first vertex to render
  vertexCount | Number of vertices to render
  states | Render states to use for drawing

## ◆ sfRenderTexture_generateMipmap()

bool sfRenderTexture_generateMipmap | ( | sfRenderTexture * | renderTexture | ) |

Generate a mipmap using the current texture data.

This function is similar to sfTexture_generateMipmap and operates on the texture used as the target for drawing. Be aware that any draw operation may modify the base level image data. For this reason, calling this function only makes sense after all drawing is completed and display has been called. Not calling display after subsequent drawing will lead to undefined behavior if a mipmap had been previously generated.

Returns
  true if mipmap generation was successful, false if unsuccessful

## ◆ sfRenderTexture_getDefaultView()

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

## ◆ sfRenderTexture_getMaximumAntiAliasingLevel()

unsigned int sfRenderTexture_getMaximumAntiAliasingLevel | ( | void |  | ) |

Get the maximum anti-aliasing level supported by the system.

Returns
  The maximum anti-aliasing level supported by the system

## ◆ sfRenderTexture_getScissor()

sfIntRect sfRenderTexture_getScissor | ( | const sfRenderTexture * | renderTexture,
|  | const sfView * | view )

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

The scissor rectangle is defined in the view as a ratio. This function simply applies this ratio to the current dimensions of the render target to calculate the pixels rectangle that the scissor rectangle actually covers in the target.

Parameters

  renderTexture | Render texture object
  view | The view for which we want to compute the scissor rectangle

Returns
  Scissor rectangle, expressed in pixels

## ◆ sfRenderTexture_getSize()

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

## ◆ sfRenderTexture_getTexture()

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

## ◆ sfRenderTexture_getView()

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

## ◆ sfRenderTexture_getViewport()

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

## ◆ sfRenderTexture_isRepeated()

bool sfRenderTexture_isRepeated | ( | const sfRenderTexture * | renderTexture | ) |

Tell whether the texture is repeated or not.

Parameters

  renderTexture | Render texture object

Returns
  true if repeat mode is enabled, false if it is disabled

## ◆ sfRenderTexture_isSmooth()

bool sfRenderTexture_isSmooth | ( | const sfRenderTexture * | renderTexture | ) |

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

Parameters

  renderTexture | Render texture object

Returns
  true if smoothing is enabled, false if it is disabled

## ◆ sfRenderTexture_isSrgb()

bool sfRenderTexture_isSrgb | ( | const sfRenderTexture * | renderTexture | ) |

Tell if the render texture will use sRGB encoding when drawing on it.

Parameters

  renderTexture | Render texture object

Returns
  true if the render texture use sRGB encoding, false otherwise

## ◆ sfRenderTexture_mapCoordsToPixel()

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)

## ◆ sfRenderTexture_mapPixelToCoords()

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

## ◆ sfRenderTexture_popGLStates()

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

## ◆ sfRenderTexture_pushGLStates()

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

## ◆ sfRenderTexture_resetGLStates()

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

## ◆ sfRenderTexture_setActive()

bool sfRenderTexture_setActive | ( | sfRenderTexture * | renderTexture,
|  | bool | active )

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

Parameters

  renderTexture | Render texture object
  active | true to activate, false to deactivate

Returns
  True if operation was successful, false otherwise

## ◆ sfRenderTexture_setRepeated()

void sfRenderTexture_setRepeated | ( | sfRenderTexture * | renderTexture,
|  | bool | repeated )

Enable or disable texture repeating.

Parameters

  renderTexture | Render texture object
  repeated | true to enable repeating, false to disable it

## ◆ sfRenderTexture_setSmooth()

void sfRenderTexture_setSmooth | ( | sfRenderTexture * | renderTexture,
|  | bool | smooth )

Enable or disable the smooth filter on a render texture.

Parameters

  renderTexture | Render texture object
  smooth | true to enable smoothing, false to disable it

## ◆ sfRenderTexture_setView()

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