diff options
author | Nikolas <nikolas@boutalas.com> | 2024-10-27 12:52:55 +0200 |
---|---|---|
committer | Nikolas <nikolas@boutalas.com> | 2024-10-27 12:52:55 +0200 |
commit | 43394c8a8908442982e3a7e25975c31b3c952923 (patch) | |
tree | 2facd563e29f48fe3b0653ac5c113998940b4d5e /graphics/texture.h |
Diffstat (limited to 'graphics/texture.h')
-rw-r--r-- | graphics/texture.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/graphics/texture.h b/graphics/texture.h new file mode 100644 index 0000000..c0d16e3 --- /dev/null +++ b/graphics/texture.h @@ -0,0 +1,36 @@ +#pragma once +#include <GL/glew.h> +#include <string> +#include <unordered_map> +#include <vector> + +namespace graphics +{ + class Texture + { + private: + GLuint m_id = 0; + std::string m_filename; + unsigned int m_width, m_height; + unsigned int m_channels; + std::vector<unsigned char> m_buffer; + bool m_ready = false; + void makePowerOfTwo(); + bool load(const std::string & file); + void buildGLTexture(); + public: + Texture(const std::string & filename); + GLuint getID() { return m_id; } + int getWidth() { return m_width; } + int getHeight() { return m_height; } + + }; + + class TextureManager + { + private: + std::unordered_map<std::string, Texture> textures; + public: + GLuint getTexture(std::string file); + }; +} |