Path-keyed cache that prevents the same image from being uploaded twice.
std::shared_ptr< Texture > GetOrLoadTexture(const std::string &path)
Return a cached texture, loading it from disk on first request.
2D OpenGL texture object wrapping a GL_TEXTURE_2D handle.
void Init(int width, int height, int numChannels, unsigned char *data)
(Re-)initialise the texture with new pixel data. Called by the constructor; can also re-upload change...
~Texture()
Calls glDeleteTextures() to release the GPU handle.
static std::shared_ptr< Texture > LoadFromMemory(const unsigned char *data, int sizeBytes)
Decode an in-memory image (PNG/JPG/...) into a GPU texture.
static std::shared_ptr< Texture > Load(const std::string &path)
Load a texture from a file path using stb_image.
GLuint GetID() const
Returns the underlying OpenGL texture handle (GL_TEXTURE_2D target).