raylib-cpp
C++ object-oriented wrapper library for raylib.
Public Member Functions | List of all members
raylib::Texture Class Reference

Texture type. More...

Public Member Functions

 Texture (const ::Image &image)
 Creates a texture from the given Image. More...
 
 Texture (const ::Image &image, int layout)
 Load cubemap from image, multiple image cubemap layouts supported. More...
 
 Texture (const ::Texture &texture)
 Creates a texture object based on the given Texture struct data.
 
 Texture (const std::string &fileName)
 Load texture from file into GPU memory (VRAM) More...
 
 Texture (const Texture &)=delete
 
 Texture (Texture &&other)
 
 Texture (unsigned int id=0, int width=0, int height=0, int mipmaps=0, int format=0)
 Default constructor to create an empty Texture object.
 
TextureDraw (::NPatchInfo nPatchInfo, ::Rectangle destRec, ::Vector2 origin={0, 0}, float rotation=0, ::Color tint={255, 255, 255, 255})
 
TextureDraw (::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin={0, 0}, float rotation=0, ::Color tint={255, 255, 255, 255})
 
TextureDraw (::Rectangle sourceRec, ::Vector2 position={0, 0}, ::Color tint={255, 255, 255, 255})
 
TextureDraw (::Vector2 position, ::Color tint={255, 255, 255, 255})
 
TextureDraw (::Vector2 position, float rotation, float scale=1.0f, ::Color tint={255, 255, 255, 255})
 
TextureDraw (::Vector2 tiling, ::Vector2 offset, ::Rectangle quad, ::Color tint={255, 255, 255, 255})
 
TextureDraw (::Vector3 position, float width, float height, float length, ::Color tint={255, 255, 255, 255})
 
TextureDraw (int posX=0, int posY=0, ::Color tint={255, 255, 255, 255})
 Draw a Texture2D.
 
TextureDrawPoly (Vector2 center, Vector2 *points, Vector2 *texcoords, int pointsCount, Color tint={255, 255, 255, 255})
 
TextureDrawTiled (::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin={0, 0}, float rotation=0, float scale=1, Color tint={255, 255, 255, 255})
 
TextureGenMipmaps ()
 Generate GPU mipmaps for a texture.
 
inline ::Image GetData () const
 Get pixel data from GPU texture and return an Image.
 
int GetFormat () const
 Retrieves the format value for the object. More...
 
int GetHeight () const
 Retrieves the height value for the object. More...
 
unsigned int GetId () const
 Retrieves the id value for the object. More...
 
int GetMipmaps () const
 Retrieves the mipmaps value for the object. More...
 
inline ::Vector2 GetSize () const
 Retrieve the width and height of the texture.
 
int GetWidth () const
 Retrieves the width value for the object. More...
 
bool IsReady () const
 Determines whether or not the Texture has been loaded and is ready. More...
 
bool Load (const ::Image &image)
 Load texture from image data.
 
bool Load (const ::Image &image, int layoutType)
 Load cubemap from image, multiple image cubemap layouts supported.
 
bool Load (const std::string &fileName)
 Load texture from file into GPU memory (VRAM)
 
 operator raylib::Image ()
 Get pixel data from GPU texture and return an Image.
 
Textureoperator= (const ::Texture &texture)
 
Textureoperator= (const Texture &)=delete
 
Textureoperator= (Texture &&other)
 
TextureSetFilter (int filterMode)
 Set texture scaling filter mode.
 
void SetFormat (int value)
 Sets the format value for the object. More...
 
void SetHeight (int value)
 Sets the height value for the object. More...
 
void SetId (unsigned int value)
 Sets the id value for the object. More...
 
TextureSetMaterial (::Material *material, int mapType=MATERIAL_MAP_NORMAL)
 Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...)
 
TextureSetMaterial (const ::Material &material, int mapType=MATERIAL_MAP_NORMAL)
 
void SetMipmaps (int value)
 Sets the mipmaps value for the object. More...
 
TextureSetShaderValue (const ::Shader &shader, int locIndex)
 Set shader uniform value for texture (sampler2d)
 
TextureSetShapes (const ::Rectangle &source)
 Set texture and rectangle to be used on shapes drawing.
 
void SetWidth (int value)
 Sets the width value for the object. More...
 
TextureSetWrap (int wrapMode)
 Set texture wrapping mode.
 
void Unload ()
 Unload texture from GPU memory (VRAM)
 
TextureUpdate (::Rectangle rec, const void *pixels)
 Update GPU texture rectangle with new data.
 
TextureUpdate (const void *pixels)
 Update GPU texture with new data.
 

Detailed Description

Texture type.

Definition at line 16 of file Texture.hpp.

Constructor & Destructor Documentation

◆ Texture() [1/3]

raylib::Texture::Texture ( const ::Image image)
inline

Creates a texture from the given Image.

Exceptions
raylib::RaylibExceptionThrows if failed to create the texture from the given image.

Definition at line 41 of file Texture.hpp.

References Load().

◆ Texture() [2/3]

raylib::Texture::Texture ( const ::Image image,
int  layout 
)
inline

Load cubemap from image, multiple image cubemap layouts supported.

Exceptions
raylib::RaylibExceptionThrows if failed to create the texture from the given cubemap.
See also
LoadTextureCubemap()

Definition at line 54 of file Texture.hpp.

References Load().

◆ Texture() [3/3]

raylib::Texture::Texture ( const std::string &  fileName)
inline

Load texture from file into GPU memory (VRAM)

Exceptions
raylib::RaylibExceptionThrows if failed to create the texture from the given file.

Definition at line 65 of file Texture.hpp.

References Load().

Member Function Documentation

◆ GetFormat()

int raylib::Texture::GetFormat ( ) const
inline

Retrieves the format value for the object.

Returns
The format value of the object.

Definition at line 91 of file Texture.hpp.

◆ GetHeight()

int raylib::Texture::GetHeight ( ) const
inline

Retrieves the height value for the object.

Returns
The height value of the object.

Definition at line 89 of file Texture.hpp.

◆ GetId()

unsigned int raylib::Texture::GetId ( ) const
inline

Retrieves the id value for the object.

Returns
The id value of the object.

Definition at line 87 of file Texture.hpp.

◆ GetMipmaps()

int raylib::Texture::GetMipmaps ( ) const
inline

Retrieves the mipmaps value for the object.

Returns
The mipmaps value of the object.

Definition at line 90 of file Texture.hpp.

◆ GetWidth()

int raylib::Texture::GetWidth ( ) const
inline

Retrieves the width value for the object.

Returns
The width value of the object.

Definition at line 88 of file Texture.hpp.

◆ IsReady()

bool raylib::Texture::IsReady ( ) const
inline

Determines whether or not the Texture has been loaded and is ready.

Returns
True or false depending on whether the Texture has data.

Definition at line 305 of file Texture.hpp.

Referenced by Load().

◆ SetFormat()

void raylib::Texture::SetFormat ( int  value)
inline

Sets the format value for the object.

Parameters
valueThe value of which to set format to.

Definition at line 91 of file Texture.hpp.

◆ SetHeight()

void raylib::Texture::SetHeight ( int  value)
inline

Sets the height value for the object.

Parameters
valueThe value of which to set height to.

Definition at line 89 of file Texture.hpp.

◆ SetId()

void raylib::Texture::SetId ( unsigned int  value)
inline

Sets the id value for the object.

Parameters
valueThe value of which to set id to.

Definition at line 87 of file Texture.hpp.

◆ SetMipmaps()

void raylib::Texture::SetMipmaps ( int  value)
inline

Sets the mipmaps value for the object.

Parameters
valueThe value of which to set mipmaps to.

Definition at line 90 of file Texture.hpp.

◆ SetWidth()

void raylib::Texture::SetWidth ( int  value)
inline

Sets the width value for the object.

Parameters
valueThe value of which to set width to.

Definition at line 88 of file Texture.hpp.