Texture

Image living on the graphics card that can be used for drawing.

Constructors

this
this()

Default constructor * Creates an empty texture.

Destructor

~this
~this()

Destructor.

Members

Functions

copyToImage
Image copyToImage()

Copy the texture pixels to an image. * This function performs a slow operation that downloads the texture's pixels from the graphics card and copies them to a new image, potentially applying transformations to pixels if necessary (texture may be padded or flipped). *

create
bool create(uint width, uint height)

Create the texture. * If this function fails, the texture is left unchanged. *

getSize
Vector2u getSize()

Return the size of the texture. *

isRepeated
bool isRepeated()

Tell whether the texture is repeated or not. *

isSmooth
bool isSmooth()

Tell whether the smooth filter is enabled or not. *

loadFromFile
bool loadFromFile(const(char)[] filename, IntRect area = IntRect())

Load the texture from a file on disk. * The area argument can be used to load only a sub-rectangle of the whole image. If you want the entire image then leave the default value (which is an empty IntRect). If the area rectangle crosses the bounds of the image, it is adjusted to fit the image size. * The maximum size for a texture depends on the graphics driver and can be retrieved with the getMaximumSize function. * If this function fails, the texture is left unchanged. *

loadFromImage
bool loadFromImage(Image image, IntRect area = IntRect())

Load the texture from an image. * The area argument can be used to load only a sub-rectangle of the whole image. If you want the entire image then leave the default value (which is an empty IntRect). If the area rectangle crosses the bounds of the image, it is adjusted to fit the image size. * The maximum size for a texture depends on the graphics driver and can be retrieved with the getMaximumSize function. * If this function fails, the texture is left unchanged. *

loadFromMemory
bool loadFromMemory(const(void)[] data, IntRect area = IntRect())

Load the texture from a file in memory. * The area argument can be used to load only a sub-rectangle of the whole image. If you want the entire image then leave the default value (which is an empty IntRect). If the area rectangle crosses the bounds of the image, it is adjusted to fit the image size. * The maximum size for a texture depends on the graphics driver and can be retrieved with the getMaximumSize function. * If this function fails, the texture is left unchanged. *

loadFromStream
bool loadFromStream(InputStream stream, IntRect area = IntRect())

Load the texture from a custom stream. * The area argument can be used to load only a sub-rectangle of the whole image. If you want the entire image then leave the default value (which is an empty IntRect). If the area rectangle crosses the bounds of the image, it is adjusted to fit the image size. * The maximum size for a texture depends on the graphics driver and can be retrieved with the getMaximumSize function. * If this function fails, the texture is left unchanged. *

setRepeated
void setRepeated(bool repeated)

Enable or disable repeating. * 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. *

setSmooth
void setSmooth(bool smooth)

Enable or disable the smooth filter. * When the filter is activated, the texture appears smoother so that pixels are less noticeable. However if you want the texture to look exactly the same as its source file, you should leave it disabled. The smooth filter is disabled by default. *

update
void update(const(ubyte)[] pixels)

Update the whole texture from an array of pixels. * The pixel array is assumed to have the same size as the area rectangle, and to contain 32-bits RGBA pixels. * No additional check is performed on the size of the pixel array, passing invalid arguments will lead to an undefined behavior. * This function does nothing if pixels is empty or if the texture was not previously created. *

update
void update(const(ubyte)[] pixels, uint width, uint height, uint x, uint y)

Update part of the texture from an array of pixels. * The size of the pixel array must match the width and height arguments, and it must contain 32-bits RGBA pixels. * No additional check is performed on the size of the pixel array or the bounds of the area to update, passing invalid arguments will lead to an undefined behaviour. * This function does nothing if pixels is empty or if the texture was not previously created. *

update
void update(const(Image) image)

Update the texture from an image. * Although the source image can be smaller than the texture, this function is usually used for updating the whole texture. The other overload, which has (x, y) additional arguments, is more convenient for updating a sub-area of the texture. * No additional check is performed on the size of the image, passing an image bigger than the texture will lead to an undefined behaviour. * This function does nothing if the texture was not previously created. *

update
void update(const(Image) image, uint x, uint y)

Update the texture from an image. * No additional check is performed on the size of the image, passing an invalid combination of image size and offset will lead to an undefined behavior. * This function does nothing if the texture was not previously created. *

update
void update(const(T) window)

Update the texture from the contents of a window * Although the source window can be smaller than the texture, this function is usually used for updating the whole texture. The other overload, which has (x, y) additional arguments, is more convenient for updating a sub-area of the texture. * No additional check is performed on the size of the window, passing a window bigger than the texture will lead to an undefined behavior. * This function does nothing if either the texture or the window was not previously created. *

update
void update(const(T) window, uint x, uint y)

Update a part of the texture from the contents of a window. * No additional check is performed on the size of the window, passing an invalid combination of window size and offset will lead to an undefined behavior. * This function does nothing if either the texture or the window was not previously created. *

updateFromImage
void updateFromImage(Image image, uint x, uint y)

Update the texture from an image. * Although the source image can be smaller than the texture, this function is usually used for updating the whole texture. The other overload, which has (x, y) additional arguments, is more convenient for updating a sub-area of the texture. * No additional check is performed on the size of the image, passing an image bigger than the texture will lead to an undefined behaviour. * This function does nothing if the texture was not previously created. *

updateFromPixels
void updateFromPixels(const(ubyte)[] pixels, uint width, uint height, uint x, uint y)

Update part of the texture from an array of pixels. * The size of the pixel array must match the width and height arguments, and it must contain 32-bits RGBA pixels. * No additional check is performed on the size of the pixel array or the bounds of the area to update, passing invalid arguments will lead to an undefined behaviour. * This function does nothing if pixels is null or if the texture was not previously created. *

updateFromWindow
void updateFromWindow(Window window, uint x, uint y)

Update a part of the texture from the contents of a window. * No additional check is performed on the size of the window, passing an invalid combination of window size and offset will lead to an undefined behaviour. * This function does nothing if either the texture or the window was not previously created. *

updateFromWindow
void updateFromWindow(RenderWindow window, uint x, uint y)

Update a part of the texture from the contents of a window. * No additional check is performed on the size of the window, passing an invalid combination of window size and offset will lead to an undefined behaviour. * This function does nothing if either the texture or the window was not previously created. *

Properties

dup
Texture dup [@property getter]

Creates a new texture from the same data (this means copying the entire set of pixels).

Static functions

bind
void bind(Texture texture)

Bind a texture for rendering. * This function is not part of the graphics API, it mustn't be used when drawing DSFML entities. It must be used only if you mix Texture with OpenGL code. *

getMaximumSize
uint getMaximumSize()

Get the maximum texture size allowed. * This Maximum size is defined by the graphics driver. You can expect a value of 512 pixels for low-end graphics card, and up to 8192 pixels or more for newer hardware. *

Meta