galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::Texture Class Referencefinal

Bindless OpenGL 2D Texture. More...

#include <Texture.hpp>

+ Collaboration diagram for galaxy::Texture:

Public Member Functions

 Texture ()
 Constructor.
 
 Texture (Texture &&) noexcept
 Move constructor.
 
Textureoperator= (Texture &&) noexcept
 Move assignment operator.
 
 ~Texture ()
 Destructor.
 
bool load (const std::string &file)
 Load a texture from vfs.
 
bool load_mem (std::span< std::uint8_t > buffer)
 Loads texture from memory.
 
void save (std::string_view file)
 Saves texture to file on disk.
 
void bind () const noexcept
 Bind to sampler.
 
void unbind () const noexcept
 Deactivate sampler.
 
void destroy ()
 Destroy texture.
 
void recreate ()
 Deletes texture data and configuration in OpenGL.
 
float width () const noexcept
 Get texture width.
 
float height () const noexcept
 Get texture height.
 
unsigned int id () const noexcept
 Get OpenGL texture id.
 
std::uint64_t handle () const noexcept
 Get OpenGL bindless handle.
 

Private Member Functions

 Texture (const Texture &)=delete
 Copy constructor.
 
Textureoperator= (const Texture &)=delete
 Copy assignment operator.
 
void set_filter () const noexcept
 Sets filter when texture is (up/down)scaled in OpenGL.
 
void set_mode () const noexcept
 Set texture mode.
 
void set_anisotropy () const noexcept
 Set ansiotropic filtering level.
 

Private Attributes

unsigned int m_id
 OpenGL id.
 
std::uint64_t m_handle
 Bindless handle.
 
int m_width
 Texture width.
 
int m_height
 Texture height.
 

Detailed Description

Bindless OpenGL 2D Texture.

https://ktstephano.github.io/rendering/opengl/bindless

Definition at line 21 of file Texture.hpp.

Constructor & Destructor Documentation

◆ Texture() [1/3]

galaxy::Texture::Texture ( )

Constructor.

Definition at line 28 of file Texture.cpp.

◆ Texture() [2/3]

galaxy::Texture::Texture ( Texture && t)
noexcept

Move constructor.

Definition at line 37 of file Texture.cpp.

◆ ~Texture()

galaxy::Texture::~Texture ( )

Destructor.

Definition at line 68 of file Texture.cpp.

+ Here is the call graph for this function:

◆ Texture() [3/3]

galaxy::Texture::Texture ( const Texture & )
privatedelete

Copy constructor.

Member Function Documentation

◆ operator=() [1/2]

Texture & galaxy::Texture::operator= ( Texture && t)
noexcept

Move assignment operator.

Definition at line 50 of file Texture.cpp.

◆ load()

bool galaxy::Texture::load ( const std::string & file)
nodiscard

Load a texture from vfs.

Parameters
fileTexture in VFS to load.
Returns
True if texture loaded successfully.

Definition at line 73 of file Texture.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_mem()

bool galaxy::Texture::load_mem ( std::span< std::uint8_t > buffer)
nodiscard

Loads texture from memory.

Loads from standard 256byte array.

Parameters
bufferMemory buffer to load from.
Returns
True if texture loaded successfully.

Definition at line 81 of file Texture.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

void galaxy::Texture::save ( std::string_view file)

Saves texture to file on disk.

Parameters
filePath and filename to save texture to. Does not need extension (it will be ignored).

Definition at line 119 of file Texture.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bind()

void galaxy::Texture::bind ( ) const
noexcept

Bind to sampler.

Not required because this supports bindless textures.

Definition at line 157 of file Texture.cpp.

+ Here is the caller graph for this function:

◆ unbind()

void galaxy::Texture::unbind ( ) const
noexcept

Deactivate sampler.

Definition at line 162 of file Texture.cpp.

+ Here is the caller graph for this function:

◆ destroy()

void galaxy::Texture::destroy ( )

Destroy texture.

Definition at line 167 of file Texture.cpp.

+ Here is the caller graph for this function:

◆ recreate()

void galaxy::Texture::recreate ( )

Deletes texture data and configuration in OpenGL.

You need to call load again!

Definition at line 182 of file Texture.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ width()

float galaxy::Texture::width ( ) const
nodiscardnoexcept

Get texture width.

Is cached for performance.

Returns
Width as float.

Definition at line 188 of file Texture.cpp.

+ Here is the caller graph for this function:

◆ height()

float galaxy::Texture::height ( ) const
nodiscardnoexcept

Get texture height.

Is cached for performance.

Returns
Height as float.

Definition at line 193 of file Texture.cpp.

+ Here is the caller graph for this function:

◆ id()

unsigned int galaxy::Texture::id ( ) const
nodiscardnoexcept

Get OpenGL texture id.

Returns
Unsigned int.

Definition at line 198 of file Texture.cpp.

+ Here is the caller graph for this function:

◆ handle()

std::uint64_t galaxy::Texture::handle ( ) const
nodiscardnoexcept

Get OpenGL bindless handle.

Returns
Unsigned long long.

Definition at line 203 of file Texture.cpp.

+ Here is the caller graph for this function:

◆ operator=() [2/2]

Texture & galaxy::Texture::operator= ( const Texture & )
privatedelete

Copy assignment operator.

◆ set_filter()

void galaxy::Texture::set_filter ( ) const
privatenoexcept

Sets filter when texture is (up/down)scaled in OpenGL.

Includes mipmapping.

Definition at line 208 of file Texture.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_mode()

void galaxy::Texture::set_mode ( ) const
privatenoexcept

Set texture mode.

I.e. REPEAT, CLAMP_TO_EDGE, etc.

Definition at line 245 of file Texture.cpp.

+ Here is the caller graph for this function:

◆ set_anisotropy()

void galaxy::Texture::set_anisotropy ( ) const
privatenoexcept

Set ansiotropic filtering level.

Definition at line 251 of file Texture.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_id

unsigned int galaxy::Texture::m_id
private

OpenGL id.

Definition at line 167 of file Texture.hpp.

◆ m_handle

std::uint64_t galaxy::Texture::m_handle
private

Bindless handle.

Definition at line 172 of file Texture.hpp.

◆ m_width

int galaxy::Texture::m_width
private

Texture width.

Definition at line 177 of file Texture.hpp.

◆ m_height

int galaxy::Texture::m_height
private

Texture height.

Definition at line 182 of file Texture.hpp.


The documentation for this class was generated from the following files: