Image living on the graphics card that can be used for drawing.
More...
#include <Texture.h>
Image living on the graphics card that can be used for drawing.
Definition at line 47 of file Texture.h.
◆ Ptr
shared texture pointer
Definition at line 49 of file Texture.h.
◆ Texture() [1/4]
ime::Texture::Texture |
( |
| ) |
|
Constructor.
Creates an empty texture of size {0, 0}
- See also
- loadFromFile
◆ Texture() [2/4]
ime::Texture::Texture |
( |
const std::string & |
filename, |
|
|
const UIntRect & |
area = UIntRect() |
|
) |
| |
|
explicit |
Construct the texture.
- Parameters
-
filename | Filename of the image file to load |
area | Area of the image to load |
- Exceptions
-
The area can be used to construct the texture from a sub-rectangle of the whole image. To construct the texture from the whole image (default), leave the area argument unspecified. If the area rectangle crosses the bounds of the image, it is adjusted to fit the image size
◆ Texture() [3/4]
ime::Texture::Texture |
( |
const Texture & |
| ) |
|
◆ Texture() [4/4]
ime::Texture::Texture |
( |
Texture && |
| ) |
|
|
noexcept |
◆ ~Texture()
ime::Texture::~Texture |
( |
| ) |
|
◆ create() [1/2]
bool ime::Texture::create |
( |
const Vector2u & |
size | ) |
|
Create an empty texture.
- Parameters
-
size | The size of the texture |
- Returns
- True if the texture was created successfully, or false if the creation failed
You can use this function if you want the texture to have a size but intend to load the image file at a later time.
This function fails if the specified size is invalid. The size must be greater than zero but less than the maximum allowed size of the texture (see getMaximumSize()). If this function fails, the texture is left unchanged
- See also
- loadFromFile
◆ create() [2/2]
bool ime::Texture::create |
( |
unsigned int |
width, |
|
|
unsigned int |
height |
|
) |
| |
Create an empty texture.
- Parameters
-
width | The width of the texture |
height | The height of the texture |
- Returns
- True if the texture was created successfully, or false if the creation failed
You can use this function if you want the texture to have a size but intend to load the image file at a later time.
This function fails if the specified size is invalid. The size must be greater than zero but less than the maximum allowed size of the texture (see getMaximumSize()). If this function fails, the texture is left unchanged
- See also
- loadFromFile
◆ getFilename()
const std::string & ime::Texture::getFilename |
( |
| ) |
const |
Get the filename of the image the texture was loaded from.
- Returns
- The filename of the image the texture was created from
◆ getMaximumSize()
static unsigned int ime::Texture::getMaximumSize |
( |
| ) |
|
|
static |
Get the maximum texture size allowed.
- Returns
- The maximum size allowed for textures, in pixels
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.
◆ getSize()
Vector2u ime::Texture::getSize |
( |
| ) |
const |
Get the size of the texture.
- Returns
- The size of the texture in pixels
◆ isRepeated()
bool ime::Texture::isRepeated |
( |
| ) |
const |
Check whether the texture is repeated or not.
- Returns
- True if repeat mode is enabled, false if it is disabled
- See also
- setRepeated
◆ isSmooth()
bool ime::Texture::isSmooth |
( |
| ) |
const |
Check whether the smooth filter is enabled or not.
- Returns
- True if smoothing is enabled, false if it is disabled
- See also
- setSmooth
◆ loadFromFile()
void ime::Texture::loadFromFile |
( |
const std::string & |
filename, |
|
|
const UIntRect & |
area = UIntRect() |
|
) |
| |
Load the texture from an image on the disk.
- Parameters
-
filename | Filename of the image file to load |
area | Area of the image to load |
- Exceptions
-
The area can be used to construct the texture from a sub-rectangle of the whole image. To construct the texture from the whole image (default), leave the area argument unspecified. If the area rectangle crosses the bounds of the image, it is adjusted to fit the image size
◆ operator!=()
bool ime::Texture::operator!= |
( |
const Texture & |
other | ) |
const |
Check if this texture is not the same as another texture.
- Parameters
-
other | The texture to compare against this texture |
- Returns
- True if the two textures are not the same, otherwise false
◆ operator=() [1/2]
Copy assignment operator.
◆ operator=() [2/2]
Move assignment operator.
◆ saveToFile()
bool ime::Texture::saveToFile |
( |
const std::string & |
filename | ) |
|
Save the texture to file on disk.
- Parameters
-
filename | Path of the file to save |
- Returns
- True if the texture was saved successfully, or false if the texture is empty
The format of the image is automatically deduced from the file extension. The supported image formats are bmp, png, tga and jpg. The destination file is overwritten if it already exists
- Note
- This function performs a slow operation
◆ setRepeated()
void ime::Texture::setRepeated |
( |
bool |
repeated | ) |
|
Enable or disable repeating.
- Parameters
-
repeated | True to repeat the texture, false to 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.
Repeating is disabled by default.
- 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).
◆ setSmooth()
void ime::Texture::setSmooth |
( |
bool |
smooth | ) |
|
Enable or disable the smooth filter.
- Parameters
-
smooth | True to enable smoothing or false to disable it |
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
The documentation for this class was generated from the following file: