CSFML

- Main Page
- Data Structures
- Files

- File List
- Globals

Functions
Texture.h File Reference
`#include <SFML/Graphics/Export.h>`
`#include <SFML/Graphics/Rect.h>`
`#include <SFML/Graphics/Types.h>`
`#include <SFML/Window/Types.h>`
`#include <SFML/System/InputStream.h>`
`#include <SFML/System/Vector2.h>`
`#include <stddef.h>`

Go to the source code of this file.

## Functions

CSFML_GRAPHICS_API sfTexture * | sfTexture_create (unsigned int width, unsigned int height)
| Create a new texture. More...
CSFML_GRAPHICS_API sfTexture * | sfTexture_createFromFile (const char *filename, const sfIntRect *area)
| Create a new texture from a file. More...
CSFML_GRAPHICS_API sfTexture * | sfTexture_createFromMemory (const void *data, size_t sizeInBytes, const sfIntRect *area)
| Create a new texture from a file in memory. More...
CSFML_GRAPHICS_API sfTexture * | sfTexture_createFromStream (sfInputStream *stream, const sfIntRect *area)
| Create a new texture from a custom stream. More...
CSFML_GRAPHICS_API sfTexture * | sfTexture_createFromImage (const sfImage *image, const sfIntRect *area)
| Create a new texture from an image. More...
CSFML_GRAPHICS_API sfTexture * | sfTexture_copy (const sfTexture *texture)
| Copy an existing texture. More...
CSFML_GRAPHICS_API void | sfTexture_destroy (sfTexture *texture)
| Destroy an existing texture. More...
CSFML_GRAPHICS_API sfVector2u | sfTexture_getSize (const sfTexture *texture)
| Return the size of the texture. More...
CSFML_GRAPHICS_API sfImage * | sfTexture_copyToImage (const sfTexture *texture)
| Copy a texture's pixels to an image. More...
CSFML_GRAPHICS_API void | sfTexture_updateFromPixels (sfTexture *texture, const sfUint8 *pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y)
| Update a texture from an array of pixels. More...
CSFML_GRAPHICS_API void | sfTexture_updateFromImage (sfTexture *texture, const sfImage *image, unsigned int x, unsigned int y)
| Update a texture from an image. More...
CSFML_GRAPHICS_API void | sfTexture_updateFromWindow (sfTexture *texture, const sfWindow *window, unsigned int x, unsigned int y)
| Update a texture from the contents of a window. More...
CSFML_GRAPHICS_API void | sfTexture_updateFromRenderWindow (sfTexture *texture, const sfRenderWindow *renderWindow, unsigned int x, unsigned int y)
| Update a texture from the contents of a render-window. More...
CSFML_GRAPHICS_API void | sfTexture_setSmooth (sfTexture *texture, sfBool smooth)
| Enable or disable the smooth filter on a texture. More...
CSFML_GRAPHICS_API sfBool | sfTexture_isSmooth (const sfTexture *texture)
| Tell whether the smooth filter is enabled or not for a texture. More...
CSFML_GRAPHICS_API void | sfTexture_setRepeated (sfTexture *texture, sfBool repeated)
| Enable or disable repeating for a texture. More...
CSFML_GRAPHICS_API sfBool | sfTexture_isRepeated (const sfTexture *texture)
| Tell whether a texture is repeated or not. More...
CSFML_GRAPHICS_API void | sfTexture_bind (const sfTexture *texture)
| Bind a texture for rendering. More...
CSFML_GRAPHICS_API unsigned int | sfTexture_getMaximumSize ()
| Get the maximum texture size allowed. More...

## Function Documentation

CSFML_GRAPHICS_API void sfTexture_bind | ( | const sfTexture * | texture | ) |

Bind a texture for rendering.

This function is not part of the graphics API, it mustn't be used when drawing SFML entities. It must be used only if you mix sfTexture with OpenGL code.

* sfTexture *t1, *t2;
* ...
* sfTexture_bind(t1);
* // draw OpenGL stuff that use t1...
* sfTexture_bind(t2);
* // draw OpenGL stuff that use t2...
* sfTexture_bind(NULL);
* // draw OpenGL stuff that use no texture...
*

Parameters

  texture | Pointer to the texture to bind, can be null to use no texture

CSFML_GRAPHICS_API sfTexture* sfTexture_copy | ( | const sfTexture * | texture | ) |

Copy an existing texture.

Parameters

  texture | Texture to copy

Returns
  Copied object

CSFML_GRAPHICS_API sfImage* sfTexture_copyToImage | ( | const sfTexture * | texture | ) |

Copy a texture's pixels to an image.

Parameters

  texture | Texture to copy

Returns
  Image containing the texture's pixels

CSFML_GRAPHICS_API sfTexture* sfTexture_create | ( | unsigned int | width,
|  | unsigned int | height
| ) |  |

Create a new texture.

Parameters

  width | Texture width
  height | Texture height

Returns
  A new sfTexture object, or NULL if it failed

CSFML_GRAPHICS_API sfTexture* sfTexture_createFromFile | ( | const char * | filename,
|  | const sfIntRect * | area
| ) |  |

Create a new texture from a file.

Parameters

  filename | Path of the image file to load
  area | Area of the source image to load (NULL to load the entire image)

Returns
  A new sfTexture object, or NULL if it failed

CSFML_GRAPHICS_API sfTexture* sfTexture_createFromImage | ( | const sfImage * | image,
|  | const sfIntRect * | area
| ) |  |

Create a new texture from an image.

Parameters

  image | Image to upload to the texture
  area | Area of the source image to load (NULL to load the entire image)

Returns
  A new sfTexture object, or NULL if it failed

CSFML_GRAPHICS_API sfTexture* sfTexture_createFromMemory | ( | const void * | data,
|  | size_t | sizeInBytes,
|  | const sfIntRect * | area
| ) |  |

Create a new texture from a file in memory.

Parameters

  data | Pointer to the file data in memory
  sizeInBytes | Size of the data to load, in bytes
  area | Area of the source image to load (NULL to load the entire image)

Returns
  A new sfTexture object, or NULL if it failed

CSFML_GRAPHICS_API sfTexture* sfTexture_createFromStream | ( | sfInputStream * | stream,
|  | const sfIntRect * | area
| ) |  |

Create a new texture from a custom stream.

Parameters

  stream | Source stream to read from
  area | Area of the source image to load (NULL to load the entire image)

Returns
  A new sfTexture object, or NULL if it failed

CSFML_GRAPHICS_API void sfTexture_destroy | ( | sfTexture * | texture | ) |

Destroy an existing texture.

Parameters

  texture | Texture to delete

CSFML_GRAPHICS_API unsigned int sfTexture_getMaximumSize | ( |  | ) |

Get the maximum texture size allowed.

Returns
  Maximum size allowed for textures, in pixels

CSFML_GRAPHICS_API sfVector2u sfTexture_getSize | ( | const sfTexture * | texture | ) |

Return the size of the texture.

Parameters

  texture | Texture to read

Returns
  Size in pixels

CSFML_GRAPHICS_API sfBool sfTexture_isRepeated | ( | const sfTexture * | texture | ) |

Tell whether a texture is repeated or not.

Parameters

  texture | The texture object

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

CSFML_GRAPHICS_API sfBool sfTexture_isSmooth | ( | const sfTexture * | texture | ) |

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

Parameters

  texture | The texture object

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

CSFML_GRAPHICS_API void sfTexture_setRepeated | ( | sfTexture * | texture,
|  | sfBool | repeated
| ) |  |

Enable or disable repeating for a texture.

Repeating is involved when using texture coordinates outside the texture rectangle [0, 0, width, height]. In this case, if repeat mode is enabled, the whole texture will be repeated as many times as needed to reach the coordinate (for example, if the X texture coordinate is 3 * width, the texture will be repeated 3 times). If repeat mode is disabled, the "extra space" will instead be filled with border pixels. Warning: on very old graphics cards, white pixels may appear when the texture is repeated. With such cards, repeat mode can be used reliably only if the texture has power-of-two dimensions (such as 256x128). Repeating is disabled by default.

Parameters

  texture | The texture object
  repeated | True to repeat the texture, false to disable repeating

CSFML_GRAPHICS_API void sfTexture_setSmooth | ( | sfTexture * | texture,
|  | sfBool | smooth
| ) |  |

Enable or disable the smooth filter on a texture.

Parameters

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

CSFML_GRAPHICS_API void sfTexture_updateFromImage | ( | sfTexture * | texture,
|  | const sfImage * | image,
|  | unsigned int | x,
|  | unsigned int | y
| ) |  |

Update a texture from an image.

Parameters

  texture | Texture to update
  image | Image to copy to the texture
  x | X offset in the texture where to copy the source pixels
  y | Y offset in the texture where to copy the source pixels

CSFML_GRAPHICS_API void sfTexture_updateFromPixels | ( | sfTexture * | texture,
|  | const sfUint8 * | pixels,
|  | unsigned int | width,
|  | unsigned int | height,
|  | unsigned int | x,
|  | unsigned int | y
| ) |  |

Update a texture from an array of pixels.

Parameters

  texture | Texture to update
  pixels | Array of pixels to copy to the texture
  width | Width of the pixel region contained in pixels
  height | Height of the pixel region contained in pixels
  x | X offset in the texture where to copy the source pixels
  y | Y offset in the texture where to copy the source pixels

CSFML_GRAPHICS_API void sfTexture_updateFromRenderWindow | ( | sfTexture * | texture,
|  | const sfRenderWindow * | renderWindow,
|  | unsigned int | x,
|  | unsigned int | y
| ) |  |

Update a texture from the contents of a render-window.

Parameters

  texture | Texture to update
  renderWindow | Render-window to copy to the texture
  x | X offset in the texture where to copy the source pixels
  y | Y offset in the texture where to copy the source pixels

CSFML_GRAPHICS_API void sfTexture_updateFromWindow | ( | sfTexture * | texture,
|  | const sfWindow * | window,
|  | unsigned int | x,
|  | unsigned int | y
| ) |  |

Update a texture from the contents of a window.

Parameters

  texture | Texture to update
  window | Window to copy to the texture
  x | X offset in the texture where to copy the source pixels
  y | Y offset in the texture where to copy the source pixels