SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Sleak::Texture Class Referenceabstract

#include <Texture.hpp>

Inheritance diagram for Sleak::Texture:

Public Member Functions

virtual ~Texture ()=default
virtual void Bind (uint32_t slot=0) const =0
virtual TextureFormat GetFormat () const =0
virtual uint32_t GetHeight () const =0
virtual uint64_t GetImGuiTextureID () const
virtual float GetLodBias () const
virtual TextureType GetType () const =0
virtual uint32_t GetWidth () const =0
virtual bool LoadFromFile (const std::string &filePath)=0
 Loads and uploads an image file from disk.
virtual bool LoadFromMemory (const void *data, uint32_t width, uint32_t height, TextureFormat format)=0
 Uploads raw pixel data as the texture's contents, replacing any existing image.
virtual void SetFilter (TextureFilter filter)=0
virtual void SetLodBias (float bias)
virtual void SetWrapMode (TextureWrapMode wrapMode)=0
virtual void Unbind () const =0

Detailed Description

Backend-agnostic GPU texture interface; each renderer backend supplies its own implementation.

You rarely construct one directly. Materials create and own their textures when you call a Set...Texture(path) setter, ModelLoader creates them while importing, and Sleak::UI::CreateTextureFromPixels makes one from raw pixel data for UI use. The concrete type is whatever the active backend provides, which is why every method here is virtual.

Filtering and wrap mode are set per texture, not per material, so change them on the object a material hands back. Reach for TextureFilter::Nearest on pixel art and atlases where bleeding between neighboring tiles would show, and an anisotropic mode on ground planes viewed at glancing angles.

// Load through a material, then adjust sampling on the result
material->SetDiffuseTexture("assets/textures/atlas.png");
if (Sleak::Texture* tex = material->GetDiffuseTexture()) {
SLEAK_INFO("Atlas is {}x{}", tex->GetWidth(), tex->GetHeight());
}
#define SLEAK_INFO(...)
Definition Logger.hpp:20
See also
Material, TextureFilter, TextureWrapMode, TextureFormat, ModelLoader

Definition at line 78 of file Texture.hpp.

Constructor & Destructor Documentation

◆ ~Texture()

virtual Sleak::Texture::~Texture ( )
virtualdefault

Member Function Documentation

◆ Bind()

◆ GetFormat()

◆ GetHeight()

◆ GetImGuiTextureID()

virtual uint64_t Sleak::Texture::GetImGuiTextureID ( ) const
inlinevirtual

◆ GetLodBias()

virtual float Sleak::Texture::GetLodBias ( ) const
inlinevirtual

◆ GetType()

◆ GetWidth()

◆ LoadFromFile()

virtual bool Sleak::Texture::LoadFromFile ( const std::string & filePath)
pure virtual

◆ LoadFromMemory()

virtual bool Sleak::Texture::LoadFromMemory ( const void * data,
uint32_t width,
uint32_t height,
TextureFormat format )
pure virtual

◆ SetFilter()

◆ SetLodBias()

virtual void Sleak::Texture::SetLodBias ( float bias)
inlinevirtual

◆ SetWrapMode()

◆ Unbind()