-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphics.h
98 lines (62 loc) · 1.86 KB
/
graphics.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef GRAPHICS_H_
#define GRAPHICS_H_
#include <GL/glfw.h> // For GLFW, OpenGL and GLU
#include <GL/glpng.h> // For png-loading
#include <string>
#include <sstream>
/** The constant fps that the game should run on */
const int fixedfps = 30;
enum gType {
TGA=1,
BMP,
PNG
};
enum grError {
NO_ERROR=0,
NO_SUCH_FILE,
GLFW_ERROR,
GLPNG_ERROR,
GLUT_ERROR,
POINTER_ERROR,
NO_SUPPORTED_FORMAT,
};
/** The class used for texture encapsulation.
* More detail */
class texture
{
public:
GLuint data; //< The GLuint used in calls to OpenGL
int width, height; //< Width and height of the original file
float alpha; //< Alpha value, only for png's
texture() {};
~texture() {glDeleteTextures(1, &data);};
private:
};
extern texture allText[30];
/** Main class for taking care of OpenGL-abstraction. Handles initialization, updating, drawing. */
class rendererAllmighty
{
public:
/** Will try to initialize an OpenGL context.
* More details */
bool initWindow(int width, int height, int bpp, int mode, char* title );
/** Sets the view to orthographic
* More details */
void setOrtho();
/** Loads a texture.
* More details */
grError loadTexture( char* file, gType type, texture* text );
/** Draws a sprite
* More detail */
void drawSprite( texture* sprite, int x, int y, int width, int height, float rotation, float blended );
void drawSprite( texture* sprite, int x, int y);
void drawSprite( texture* sprite, int x, int y, int width, int height);
void drawSprite( texture* sprite, int x, int y, float rotation, float blended );
/** Draw a rectangle
* More detail */
void drawRectangle( int x, int y, int w, int h, float r, float b, float g, float alpha );
/** Swap the buffers
* More detail */
void swapBuffers();
};
#endif