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
Texture.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_GRAPHICS_GL_TEXTURE_HPP_
9#define GALAXY_GRAPHICS_GL_TEXTURE_HPP_
10
11#include <string>
12#include <span>
13
14namespace galaxy
15{
21 class Texture final
22 {
23 public:
27 Texture();
28
32 Texture(Texture&&) noexcept;
33
37 Texture& operator=(Texture&&) noexcept;
38
42 ~Texture();
43
51 [[nodiscard]]
52 bool load(const std::string& file);
53
63 [[nodiscard]]
64 bool load_mem(std::span<std::uint8_t> buffer);
65
71 void save(std::string_view file);
72
78 void bind() const noexcept;
79
83 void unbind() const noexcept;
84
88 void destroy();
89
95 void recreate();
96
104 [[nodiscard]]
105 float width() const noexcept;
106
114 [[nodiscard]]
115 float height() const noexcept;
116
122 [[nodiscard]]
123 unsigned int id() const noexcept;
124
130 [[nodiscard]]
131 std::uint64_t handle() const noexcept;
132
133 private:
137 Texture(const Texture&) = delete;
138
142 Texture& operator=(const Texture&) = delete;
143
149 void set_filter() const noexcept;
150
156 void set_mode() const noexcept;
157
161 void set_anisotropy() const noexcept;
162
163 private:
167 unsigned int m_id;
168
172 std::uint64_t m_handle;
173
178
183 };
184} // namespace galaxy
185
186#endif
Bindless OpenGL 2D Texture.
Definition Texture.hpp:22
void unbind() const noexcept
Deactivate sampler.
Definition Texture.cpp:162
void set_anisotropy() const noexcept
Set ansiotropic filtering level.
Definition Texture.cpp:251
Texture & operator=(Texture &&) noexcept
Move assignment operator.
Definition Texture.cpp:50
~Texture()
Destructor.
Definition Texture.cpp:68
bool load(const std::string &file)
Load a texture from vfs.
Definition Texture.cpp:73
bool load_mem(std::span< std::uint8_t > buffer)
Loads texture from memory.
Definition Texture.cpp:81
int m_width
Texture width.
Definition Texture.hpp:177
void set_filter() const noexcept
Sets filter when texture is (up/down)scaled in OpenGL.
Definition Texture.cpp:208
std::uint64_t m_handle
Bindless handle.
Definition Texture.hpp:172
unsigned int m_id
OpenGL id.
Definition Texture.hpp:167
void save(std::string_view file)
Saves texture to file on disk.
Definition Texture.cpp:119
void set_mode() const noexcept
Set texture mode.
Definition Texture.cpp:245
Texture(const Texture &)=delete
Copy constructor.
void bind() const noexcept
Bind to sampler.
Definition Texture.cpp:157
int m_height
Texture height.
Definition Texture.hpp:182
void destroy()
Destroy texture.
Definition Texture.cpp:167
Texture()
Constructor.
Definition Texture.cpp:28
float height() const noexcept
Get texture height.
Definition Texture.cpp:193
unsigned int id() const noexcept
Get OpenGL texture id.
Definition Texture.cpp:198
void recreate()
Deletes texture data and configuration in OpenGL.
Definition Texture.cpp:182
Texture & operator=(const Texture &)=delete
Copy assignment operator.
std::uint64_t handle() const noexcept
Get OpenGL bindless handle.
Definition Texture.cpp:203
float width() const noexcept
Get texture width.
Definition Texture.cpp:188
Animated.cpp galaxy.
Definition Animated.cpp:16
STL namespace.