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.
 
TextureView get_view (const unsigned int minlevel, const unsigned int numlevels, const unsigned int minlayer, const unsigned int numlayers) const noexcept
 Generate a texture view handle.
 
void bind () const noexcept
 Bind to sampler.
 
void unbind () const noexcept
 Unbind sampler.
 
void destroy ()
 Destroy texture.
 
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.
 

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 23 of file Texture.hpp.

Constructor & Destructor Documentation

◆ Texture() [1/3]

galaxy::Texture::Texture ( )

Constructor.

Definition at line 29 of file Texture.cpp.

◆ Texture() [2/3]

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

Move constructor.

Definition at line 38 of file Texture.cpp.

◆ ~Texture()

galaxy::Texture::~Texture ( )

Destructor.

Definition at line 69 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 51 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 74 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 82 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 121 of file Texture.cpp.

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

◆ get_view()

TextureView galaxy::Texture::get_view ( const unsigned int minlevel,
const unsigned int numlevels,
const unsigned int minlayer,
const unsigned int numlayers ) const
nodiscardnoexcept

Generate a texture view handle.

Parameters
minlevelMipmap level.
numlevelsNumber of mipmaps to include.
minlayerSpecifies the index of the first layer to include in the view.
numlayersSpecifies the number of layers to include in the view.
Returns
TextureView object.

Definition at line 159 of file Texture.cpp.

+ 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 164 of file Texture.cpp.

+ Here is the caller graph for this function:

◆ unbind()

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

Unbind sampler.

Definition at line 169 of file Texture.cpp.

+ Here is the caller graph for this function:

◆ destroy()

void galaxy::Texture::destroy ( )

Destroy texture.

Definition at line 174 of file Texture.cpp.

+ 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 189 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 194 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 199 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 204 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.

Member Data Documentation

◆ m_id

unsigned int galaxy::Texture::m_id
private

OpenGL id.

Definition at line 156 of file Texture.hpp.

◆ m_handle

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

Bindless handle.

Definition at line 161 of file Texture.hpp.

◆ m_width

int galaxy::Texture::m_width
private

Texture width.

Definition at line 166 of file Texture.hpp.

◆ m_height

int galaxy::Texture::m_height
private

Texture height.

Definition at line 171 of file Texture.hpp.


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