lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
Loading...
Searching...
No Matches
lmgl::renderer::Texture Class Reference

Manages an OpenGL texture. More...

#include <texture.hpp>

Public Member Functions

 Texture (int width, int height)
 Constructor for creating a texture with specified width and height.
 
 Texture (unsigned int id, int width, int height)
 Constructor for creating an existing texture with specified width and height.
 
 Texture (const std::string &fpath)
 Constructor for creating a texture from an image file.
 
 ~Texture ()
 Destructor for the Texture class.
 
void bind (unsigned int slot=0) const
 Binds the texture to a specified texture slot.
 
void unbind () const
 Unbinds the texture.
 
void resize (int width, int height)
 Resizes the texture to new dimensions.
 
int get_width () const
 Gets the width of the texture.
 
int get_height () const
 Gets the height of the texture.
 
unsigned int get_id () const
 Gets the OpenGL renderer ID of the texture.
 
void set_data (void *data, unsigned int size)
 Sets the data of the texture.
 

Detailed Description

Manages an OpenGL texture.

This class encapsulates the creation, binding, unbinding, resizing, and data management of an OpenGL texture. It provides methods to interact with the texture in a rendering context.

Constructor & Destructor Documentation

◆ Texture() [1/3]

lmgl::renderer::Texture::Texture ( int width,
int height )

Constructor for creating a texture with specified width and height.

Initializes an empty texture with the given dimensions.

Parameters
widthThe width of the texture.
heightThe height of the texture.

◆ Texture() [2/3]

lmgl::renderer::Texture::Texture ( unsigned int id,
int width,
int height )

Constructor for creating an existing texture with specified width and height.

Initializes an existing texture with the given dimensions.

Parameters
idThe id of the existing renderer texture.
widthThe width of the texture.
heightThe height of the texture.

◆ Texture() [3/3]

lmgl::renderer::Texture::Texture ( const std::string & fpath)

Constructor for creating a texture from an image file.

Loads the texture data from the specified file path.

Parameters
fpathThe file path to the image to load as a texture.

Member Function Documentation

◆ bind()

void lmgl::renderer::Texture::bind ( unsigned int slot = 0) const

Binds the texture to a specified texture slot.

Activates the texture for use in rendering operations.

Parameters
slotThe texture slot to bind the texture to (default is 0).

◆ get_height()

int lmgl::renderer::Texture::get_height ( ) const
inline

Gets the height of the texture.

Returns
The height of the texture.

◆ get_id()

unsigned int lmgl::renderer::Texture::get_id ( ) const
inline

Gets the OpenGL renderer ID of the texture.

Returns
The renderer ID of the texture.

◆ get_width()

int lmgl::renderer::Texture::get_width ( ) const
inline

Gets the width of the texture.

Returns
The width of the texture.

◆ resize()

void lmgl::renderer::Texture::resize ( int width,
int height )

Resizes the texture to new dimensions.

Updates the texture's width and height.

Parameters
widthThe new width of the texture.
heightThe new height of the texture.

◆ set_data()

void lmgl::renderer::Texture::set_data ( void * data,
unsigned int size )

Sets the data of the texture.

Updates the texture's data with the provided data buffer.

Parameters
dataPointer to the new texture data.
sizeSize of the new texture data in bytes.

◆ unbind()

void lmgl::renderer::Texture::unbind ( ) const

Unbinds the texture.

Deactivates the texture from the current texture slot.


The documentation for this class was generated from the following files: