blob: c0d16e3d070be93abd9922e609dedbbef51ac4c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);
};
}
|