engine::graphics::Texture class

High-level wrapper for OpenGL Texture resources.

Manages loading, GPU upload, and automatic memory cleanup.

Public static functions

static auto Load(const std::string& path) -> std::shared_ptr<Texture>
Loads an image from disk and uploads it to the GPU.

Constructors, destructors, conversion operators

~Texture()
Destructor deletes the OpenGL texture.

Public functions

void Bind(unsigned int slot = 0) const
Binds the texture to a specific texture slot.
auto id() const -> unsigned int
Gets the OpenGL ID of the texture.
auto width() const -> int
Gets the width of the texture.
auto height() const -> int
Gets the height of the texture.

Function documentation

static std::shared_ptr<Texture> engine::graphics::Texture::Load(const std::string& path)

Loads an image from disk and uploads it to the GPU.

Parameters
path File path to the image (PNG, JPG, etc.)
Returns A shared pointer to the Texture object, or nullptr if loading fails.

void engine::graphics::Texture::Bind(unsigned int slot = 0) const

Binds the texture to a specific texture slot.

Parameters
slot The texture slot to bind to (default is 0).

unsigned int engine::graphics::Texture::id() const

Gets the OpenGL ID of the texture.

Returns The renderer ID.

int engine::graphics::Texture::width() const

Gets the width of the texture.

Returns Width in pixels.

int engine::graphics::Texture::height() const

Gets the height of the texture.

Returns Height in pixels.