Public Types | Public Member Functions | Static Public Member Functions | List of all members
ime::Texture Class Reference

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

#include <Texture.h>

Public Types

using Ptr = std::shared_ptr< Texture >
 shared texture pointer More...
 

Public Member Functions

 Texture ()
 Constructor. More...
 
 Texture (const std::string &filename, const UIntRect &area=UIntRect())
 Construct the texture. More...
 
 Texture (const Texture &)
 Copy constructor. More...
 
Textureoperator= (const Texture &)
 Copy assignment operator. More...
 
 Texture (Texture &&) noexcept
 Move constructor. More...
 
Textureoperator= (Texture &&) noexcept
 Move assignment operator. More...
 
Vector2u getSize () const
 Get the size of the texture. More...
 
void setSmooth (bool smooth)
 Enable or disable the smooth filter. More...
 
bool isSmooth () const
 Check whether the smooth filter is enabled or not. More...
 
void setRepeated (bool repeated)
 Enable or disable repeating. More...
 
bool isRepeated () const
 Check whether the texture is repeated or not. More...
 
const std::string & getFilename () const
 Get the filename of the image the texture was loaded from. More...
 
const sf::Texture & getInternalTexture () const
 
 ~Texture ()
 Destructor. More...
 

Static Public Member Functions

static unsigned int getMaximumSize ()
 Get the maximum texture size allowed. More...
 

Detailed Description

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

Definition at line 41 of file Texture.h.

Member Typedef Documentation

◆ Ptr

using ime::Texture::Ptr = std::shared_ptr<Texture>

shared texture pointer

Definition at line 43 of file Texture.h.

Constructor & Destructor Documentation

◆ Texture() [1/4]

ime::Texture::Texture ( )

Constructor.

Creates an empty texture

◆ Texture() [2/4]

ime::Texture::Texture ( const std::string &  filename,
const UIntRect area = UIntRect() 
)
explicit

Construct the texture.

Parameters
filenameFilename of the image file to load
areaArea of the image to load
Exceptions
FileNotFoundif the filename cannot be found on the disk

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

Note
The maximum size for a texture depends on the graphics driver and can be retrieved with the getMaximumSize function
See also
getMaximumSize

◆ Texture() [3/4]

ime::Texture::Texture ( const Texture )

Copy constructor.

◆ Texture() [4/4]

ime::Texture::Texture ( Texture &&  )
noexcept

Move constructor.

◆ ~Texture()

ime::Texture::~Texture ( )

Destructor.

Member Function Documentation

◆ 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

◆ operator=() [1/2]

Texture& ime::Texture::operator= ( const Texture )

Copy assignment operator.

◆ operator=() [2/2]

Texture& ime::Texture::operator= ( Texture &&  )
noexcept

Move assignment operator.

◆ setRepeated()

void ime::Texture::setRepeated ( bool  repeated)

Enable or disable repeating.

Parameters
repeatedTrue 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
smoothTrue 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: