-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtexture.h
66 lines (58 loc) · 1.78 KB
/
texture.h
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef TEXTURE_H
#define TEXTURE_H
#include <QOpenGLFunctions_4_1_Core>
/**
\brief Simple class for creating textures from a bitmap file.
\author Dag Nylund
\date 16/02/05
*/
class Texture : protected QOpenGLFunctions_4_1_Core
{
private:
GLubyte pixels[16];
GLuint mId{0};
unsigned char *mBitmap;
// NB: Columns are actually width because idk...
int mColumns;
int mRows;
int mnByte;
void readBitmap(const std::string& filename);
void setTexture(GLuint textureUnit);
void initCubeMap(GLuint textureUnit = 0);
public:
Texture(GLuint textureUnit = 0); //basic texture from code
// More general constructor
Texture(const std::string& filename, GLenum type, GLuint textureUnit = 0);
GLuint id() const;
GLenum mType;
static Texture cubeMap(const std::string &filename, GLuint textureUnit = 0);
private:
//this is put inside this class to avoid spamming the main namespace
//with stuff that only is used inside this class
//Quick fix to get rid of windows.h which contains
//BITMAPINFOHEADER and BITMAPFILEHEADER.
typedef unsigned short int OWORD; //should be 16 bit
typedef unsigned int ODWORD; //should be 32 bit
typedef int OLONG; //should be 32 bit
struct OBITMAPINFOHEADER {
ODWORD biSize;
OLONG biWidth;
OLONG biHeight;
OWORD biPlanes;
OWORD biBitCount;
ODWORD biCompression;
ODWORD biSizeImage;
OLONG biXPelsPerMeter;
OLONG biYPelsPerMeter;
ODWORD biClrUsed;
ODWORD biClrImportant;
};
struct OBITMAPFILEHEADER {
OWORD bfType;
ODWORD bfSize;
OWORD bfReserved1;
OWORD bfReserved2;
ODWORD bfOffBits;
};
};
#endif // TEXTURE_H