-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.h
77 lines (56 loc) · 1.76 KB
/
renderer.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
#ifndef ____shader__
#define ____shader__
#include <string>
#include <glm/glm.hpp>
const int VERTEX_BUFFER = 0;
const int COLOR_BUFFER = 1;
const int UV_BUFFER = 1;
const int NORMAL_BUFFER = 2;
const int INDICES_BUFFER = 3;
typedef unsigned int Material;
const Material MATERIAL_RUBBER = 0;
const Material MATERIAL_METAL = 1;
const Material MATERIAL_GRASS = 2;
const Material MATERIAL_RED_METAL = 3;
const Material MATERIAL_CHAIR = 4;
void shaders_init();
void renderText(const char *text, float x, float y);
unsigned int LoadShaders(const char *vertFilePath, const char *geomFilePath, const char *fragFilePath);
class Renderer;
// Shader programs
typedef struct Program {
int programID;
Renderer *(* create)();
void(* bufferData)(Renderer *p, int type, long elements, void *data);
void(* render)(Renderer *p, glm::mat4 Model);
} Program;
extern Program *Program3D;
extern Program *ProgramText;
// Renderers
class Renderer {
private:
unsigned int *buffers;
unsigned long elements;
int numBuffers;
public:
Renderer(int numBuffers);
~Renderer();
unsigned int getNumElements() { return elements; }
void setNumElements(unsigned long num) { elements = num; }
unsigned int getBuffer(int num) { return buffers[num]; }
/* Rendering functions */
Program *program;
void bufferData(int type, long num, void *data) { program->bufferData(this, type, num, data); }
void render(glm::mat4 Model) { program->render(this, Model); }
static void pushMatrix(glm::mat4 matrix);
static void popMatrix();
Material mat;
glm::vec3 bend;
};
class TexRenderer : public Renderer {
public:
TexRenderer() : Renderer(2) {};
unsigned int texID;
void loadTexture(char *filename);
};
#endif