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
15
16namespace galaxy
17{
23 class Texture final
24 {
25 public:
29 Texture();
30
34 Texture(Texture&&) noexcept;
35
39 Texture& operator=(Texture&&) noexcept;
40
44 ~Texture();
45
53 [[nodiscard]]
54 bool load(const std::string& file);
55
65 [[nodiscard]]
66 bool load_mem(std::span<std::uint8_t> buffer);
67
73 void save(std::string_view file);
74
85 [[nodiscard]]
86 TextureView get_view(const unsigned int minlevel, const unsigned int numlevels, const unsigned int minlayer, const unsigned int numlayers) const noexcept;
87
93 void bind() const noexcept;
94
98 void unbind() const noexcept;
99
103 void destroy();
104
112 [[nodiscard]]
113 float width() const noexcept;
114
122 [[nodiscard]]
123 float height() const noexcept;
124
130 [[nodiscard]]
131 unsigned int id() const noexcept;
132
138 [[nodiscard]]
139 std::uint64_t handle() const noexcept;
140
141 private:
145 Texture(const Texture&) = delete;
146
150 Texture& operator=(const Texture&) = delete;
151
152 private:
156 unsigned int m_id;
157
161 std::uint64_t m_handle;
162
167
172 };
173} // namespace galaxy
174
175#endif
OpenGL 2D TextureView.
Bindless OpenGL 2D Texture.
Definition Texture.hpp:24
void unbind() const noexcept
Unbind sampler.
Definition Texture.cpp:169
Texture & operator=(Texture &&) noexcept
Move assignment operator.
Definition Texture.cpp:51
~Texture()
Destructor.
Definition Texture.cpp:69
bool load(const std::string &file)
Load a texture from vfs.
Definition Texture.cpp:74
bool load_mem(std::span< std::uint8_t > buffer)
Loads texture from memory.
Definition Texture.cpp:82
int m_width
Texture width.
Definition Texture.hpp:166
std::uint64_t m_handle
Bindless handle.
Definition Texture.hpp:161
unsigned int m_id
OpenGL id.
Definition Texture.hpp:156
void save(std::string_view file)
Saves texture to file on disk.
Definition Texture.cpp:121
Texture(const Texture &)=delete
Copy constructor.
void bind() const noexcept
Bind to sampler.
Definition Texture.cpp:164
int m_height
Texture height.
Definition Texture.hpp:171
void destroy()
Destroy texture.
Definition Texture.cpp:174
Texture()
Constructor.
Definition Texture.cpp:29
float height() const noexcept
Get texture height.
Definition Texture.cpp:194
unsigned int id() const noexcept
Get OpenGL texture id.
Definition Texture.cpp:199
Texture & operator=(const Texture &)=delete
Copy assignment operator.
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.
Definition Texture.cpp:159
std::uint64_t handle() const noexcept
Get OpenGL bindless handle.
Definition Texture.cpp:204
float width() const noexcept
Get texture width.
Definition Texture.cpp:189
Animated.cpp galaxy.
Definition Animated.cpp:16