Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
Texture.h File Reference

2D texture resource and a path-keyed cache (TextureManager). More...

#include <memory>
#include <string>
#include <unordered_map>
#include "graphics/GLForward.h"
+ Include dependency graph for Texture.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  mnd::Texture
 2D OpenGL texture object wrapping a GL_TEXTURE_2D handle. More...
 
class  mnd::TextureManager
 Path-keyed cache that prevents the same image from being uploaded twice. More...
 

Namespaces

namespace  mnd
 

Detailed Description

2D texture resource and a path-keyed cache (TextureManager).

Loading a texture

Prefer TextureManager::GetOrLoadTexture() over Texture::Load() directly — the manager returns the same shared_ptr for repeated requests to the same path, avoiding redundant GPU uploads.

auto tex = Engine::GetInstance().GetTextureManager()
.GetOrLoadTexture("assets/textures/wall.png");
material->SetParam("uDiffuse", tex);
std::shared_ptr< Material > material

Textures are uploaded to the GPU in Texture::Init() using stb_image for decoding. The GL texture object is deleted in the destructor.

See also
Material::SetParam, TextureManager, ShaderProgram::SetTexture

Definition in file Texture.h.