Texture class reference


Allows to load textures into the GPU's memory.

Functions documentation

Default constructor. The object created in this way is unusable until any loading function is called. Example of use:

Texture texture;
texture.Load32BitRaw(storedData, width, height);


Texture(std::string path);

Constructor with the file path from which the texture will be created.


Texture(const Texture& copy) = delete;

No copy constructor for this moment.


Destructor - frees allocated memory.


bool LoadFromMemory(unsigned char * data, size_t size);

Load the texture into memory. Version with a compressed binary data input (RGBA). If the object has previously loaded some texture, it will be removed and replaced with the new one.


void Load32BitRaw(unsigned char * bytes, int width, int height);

Load the texture into memory. Version with a decompressed binary data input (RGBA). If the object has previously loaded some texture, it will be removed and replaced with the new one.


bool IsLoaded() const;

Returns the texture loading status. A value of true means that the texture has been correctly loaded.


GLuint GetTexId() const;

Returns the texture ID associated with the GPU.


Dimension<size_t> GetDimension() const;

Returns the dimensions of the loaded texture.


std::string GetSourcePath() const;

Returns the path of the loaded file.


void Cleanup();

Deallocates memory and resets variables.


Variables documentation

Dimension<size_t> m_Dimension;

Stores the dimensions of the loaded texture.


std::string m_sTexturePath;

Stores the path of the loaded file.


GLuint m_iTextureId;

Stores the texture ID associated with the GPU/OpenGL


int m_iChannels;

Stores information about generated texture format.