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::graphics::Texture2D Class Referencefinal

Standard opengl texture. More...

#include <Texture2D.hpp>

+ Inheritance diagram for galaxy::graphics::Texture2D:
+ Collaboration diagram for galaxy::graphics::Texture2D:

Public Member Functions

 Texture2D ()
 Constructor.
 
 Texture2D (Texture2D &&)
 Move constructor.
 
Texture2Doperator= (Texture2D &&)
 Move assignment operator.
 
virtual ~Texture2D ()
 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 recreate ()
 Deletes texture data and configuration in OpenGL and creates new texture handle.
 
void bind () override
 Activate context.
 
void unbind () override
 Deactivate context.
 
- Public Member Functions inherited from galaxy::graphics::Texture
 Texture (Texture &&)
 Move constructor.
 
Textureoperator= (Texture &&)
 Move assignment operator.
 
virtual ~Texture ()
 Destructor.
 
TextureView make_view (const unsigned int minlevel=0, const unsigned int numlevels=1, const unsigned int minlayer=0, const unsigned int numlayers=1)
 Create a texture view.
 
void mode (const TextureMode mode)
 Set texture mode.
 
TextureMode mode () const
 Get texture mode.
 
void filter (const TextureFilter filter)
 Set filter when texture is (up/down)scaled in OpenGL.
 
TextureFilter filter () const
 Get texture filter.
 
void anisotropy (const int level)
 Set ansiotropic filtering level.
 
int anisotropy () const
 Get current anisotropy level.
 
float width () const
 Get texture width.
 
float height () const
 Get texture height.
 
unsigned int id () const
 Gets opengl handle.
 

Additional Inherited Members

- Protected Member Functions inherited from galaxy::graphics::Texture
 Texture ()
 Constructor.
 
- Protected Attributes inherited from galaxy::graphics::Texture
unsigned int m_id
 OpenGL id.
 
int m_width
 Cached width.
 
int m_height
 Cached height.
 
TextureMode m_mode
 Mode.
 
TextureFilter m_filter
 Filter.
 
int m_anisotropy
 Ansiotrophy level.
 

Detailed Description

Standard opengl texture.

Definition at line 20 of file Texture2D.hpp.

Constructor & Destructor Documentation

◆ Texture2D() [1/2]

galaxy::graphics::Texture2D::Texture2D ( )

Constructor.

Definition at line 27 of file Texture2D.cpp.

◆ Texture2D() [2/2]

galaxy::graphics::Texture2D::Texture2D ( Texture2D && t)

Move constructor.

Definition at line 33 of file Texture2D.cpp.

◆ ~Texture2D()

galaxy::graphics::Texture2D::~Texture2D ( )
virtual

Destructor.

Definition at line 48 of file Texture2D.cpp.

Member Function Documentation

◆ operator=()

Texture2D & galaxy::graphics::Texture2D::operator= ( Texture2D && t)

Move assignment operator.

Definition at line 38 of file Texture2D.cpp.

+ Here is the call graph for this function:

◆ load()

bool galaxy::graphics::Texture2D::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 52 of file Texture2D.cpp.

+ Here is the call graph for this function:

◆ load_mem()

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

Loads texture from memory.

Loads from standard 256 byte array.

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

Definition at line 69 of file Texture2D.cpp.

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

◆ save()

void galaxy::graphics::Texture2D::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 107 of file Texture2D.cpp.

◆ recreate()

void galaxy::graphics::Texture2D::recreate ( )

Deletes texture data and configuration in OpenGL and creates new texture handle.

Definition at line 144 of file Texture2D.cpp.

◆ bind()

void galaxy::graphics::Texture2D::bind ( )
overridevirtual

Activate context.

Implements galaxy::graphics::Texture.

Definition at line 155 of file Texture2D.cpp.

◆ unbind()

void galaxy::graphics::Texture2D::unbind ( )
overridevirtual

Deactivate context.

Implements galaxy::graphics::Texture.

Definition at line 160 of file Texture2D.cpp.


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