Shkyera Engine
Easy to use, game engine for Python
Loading...
Searching...
No Matches
Texture.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <glad/glad.h>
5#include <glm/glm.hpp>
6
7namespace shkyera {
8
9class Texture {
10 public:
11 Texture(GLenum minFilter = GL_LINEAR, GLenum magFilter = GL_LINEAR, GLenum wrapS = GL_CLAMP_TO_EDGE,
12 GLenum wrapT = GL_CLAMP_TO_EDGE);
13
14 Texture(const std::filesystem::path& path);
15
16 ~Texture();
17
18 Texture(const Texture& other) = delete;
19 Texture& operator=(const Texture& other) = delete;
20
21 Texture(Texture&& other) noexcept;
22 Texture& operator=(Texture&& other) noexcept;
23
24 // Bind and unbind texture
25 void bind() const;
26 void unbind() const;
27
28 bool loadImage(std::shared_ptr<Image> imageAsset);
29
30 // Set texture data
31 void setData(GLenum internalFormat, uint32_t width, uint32_t height, GLenum format, GLenum type,
32 const void* data = nullptr);
33
34 // Activate this texture on a specified texture unit
35 void activate(GLenum textureUnit) const;
36
37 GLuint getID() const { return _textureID; }
38
39 void* getImguiTextureID() const { return reinterpret_cast<void*>(_textureID); }
40
41 glm::vec2 getSize() const;
42
43 private:
44 Texture(std::shared_ptr<Image> image);
45
46 void generateTexture(GLenum minFilter = GL_LINEAR, GLenum magFilter = GL_LINEAR, GLenum wrapS = GL_CLAMP_TO_EDGE,
47 GLenum wrapT = GL_CLAMP_TO_EDGE);
48
49 GLuint _textureID;
50 glm::vec2 _size{};
51};
52
53} // namespace shkyera
Definition Texture.hpp:9
void unbind() const
Definition Texture.cpp:46
Texture & operator=(const Texture &other)=delete
GLuint getID() const
Definition Texture.hpp:37
Texture(const Texture &other)=delete
void generateTexture(GLenum minFilter=GL_LINEAR, GLenum magFilter=GL_LINEAR, GLenum wrapS=GL_CLAMP_TO_EDGE, GLenum wrapT=GL_CLAMP_TO_EDGE)
Definition Texture.cpp:50
void activate(GLenum textureUnit) const
Definition Texture.cpp:95
glm::vec2 getSize() const
Definition Texture.cpp:84
void * getImguiTextureID() const
Definition Texture.hpp:39
glm::vec2 _size
Definition Texture.hpp:50
void bind() const
Definition Texture.cpp:42
~Texture()
Definition Texture.cpp:36
bool loadImage(std::shared_ptr< Image > imageAsset)
Definition Texture.cpp:61
void setData(GLenum internalFormat, uint32_t width, uint32_t height, GLenum format, GLenum type, const void *data=nullptr)
Definition Texture.cpp:88
GLuint _textureID
Definition Texture.hpp:49
Definition Asset.hpp:6