|
lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
|
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. | |
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.
| 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.
| width | The width of the texture. |
| height | The height of the texture. |
| 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.
| id | The id of the existing renderer texture. |
| width | The width of the texture. |
| height | The height of the texture. |
| 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.
| fpath | The file path to the image to load as a texture. |
| 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.
| slot | The texture slot to bind the texture to (default is 0). |
|
inline |
Gets the height of the texture.
|
inline |
Gets the OpenGL renderer ID of the texture.
|
inline |
Gets the width of the texture.
| void lmgl::renderer::Texture::resize | ( | int | width, |
| int | height ) |
Resizes the texture to new dimensions.
Updates the texture's width and height.
| width | The new width of the texture. |
| height | The new height of the texture. |
| 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.
| data | Pointer to the new texture data. |
| size | Size of the new texture data in bytes. |
| void lmgl::renderer::Texture::unbind | ( | ) | const |
Unbinds the texture.
Deactivates the texture from the current texture slot.