This repository has been archived by the owner on Jan 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameMaker.hpp
148 lines (109 loc) · 3.92 KB
/
GameMaker.hpp
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#ifndef GAMEMAKER_H
#define GAMEMAKER_H
// Include standard headers
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
// Include GLEW
#include <GL/glew.h>
// Include GLFW
#include <GLFW/glfw3.h>
// GLM header file
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
using namespace glm;
// shaders header file
#include "common/shader.hpp"
#include "common/texture.hpp"
#include "common/objloader.hpp"
#include "common/text2D.hpp"
#include "common/controls.hpp"
#include "MapGenerator.hpp"
#include "Physics.hpp"
#include "Object.hpp"
#include "CubeMap.hpp"
//#include <glm/gtx/string_cast.hpp>
/**
0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, // cyan
0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, // green
1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, // red
1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, // magenta
1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, // yellow
0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, // blue
1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f // magenta
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, // white
**/
class GameMaker {
private:
CubeMap* cubeMap;
int mazeHeight, mazeWidth;
// Vertex buffer object (VBO)
GLuint cubeVertexBuffer;
GLuint floorVertexBuffer;
GLuint playerVertexBuffer;
GLuint holeVertexBuffer;
GLuint uvbuffer;
GLuint uvbuffer_floor;
GLuint uvbuffer_hole;
GLuint uvbuffer_player;
MapGenerator mg = MapGenerator();
void transferCubeToGPUMemory(void);
void transferFloorToGPUMemory(void);
void transferHoleToGPUMemory(void);
public:
float rotateX, rotateZ;
Object *player;
Object *floor, *cube, *hole;
GLuint Texture_crate;
GLuint Texture_floor;
GLuint *Texture_hole;
GLuint Texture_player;
GLuint uvmap;
btVector3 start_point = btVector3(1 + 0.5f, 0.5f, 1 + 0.5f);
btVector3 end_point = btVector3(1 + 0.5f, 0.5f, 1 + 0.5f);
bool win = false;
Physics::PhysicsWorld* physicsWorld;
Physics::PhysicsBody* playerBody;
std::vector<Physics::PhysicsBody*> objectBodies;
// Vertex array object (VAO)
GLuint VertexArrayID;
// GLSL program from the shaders
GLuint shaderTexture;
GLuint shaderLamp;
GLuint shaderMaterial;
GLuint shaderMaterialAndTexture;
GLuint shaderBasicLightning;
GLuint shaderStandard;
GLuint shaderPhong;
glm::mat4 MVP = glm::mat4(1.0f);
glm::mat4 Model = glm::mat4(1.0f);
GLfloat delta = 0.75f;
GLfloat angulo = 0.0f;
glm::vec3 winPos = glm::vec3(-999);
glm::mat4 Projection = glm::mat4(1.0f);
glm::mat4 View = glm::mat4(1.0f);
vec3 cameraAt = vec3(0.0f, 30.0f, 0.001f);
vec3 lookAt = vec3(0.0f, 0.0f, 0.0f);
GameMaker(int mazeHeight, int mazeWidth);
GameMaker(int mazeHeight, int mazeWidth, Physics::PhysicsWorld *pw);
~GameMaker();
void transferDataToGPUMemory(void);
void loadPlayer();
glm::mat4 setMVP(void);
void drawCube(glm::vec3 trans);
void drawFloor(glm::vec3 trans, bool start, bool end);
void drawHole(glm::vec3 trans);
void cleanupDataFromGPU();
void drawMap();
void drawPlayer();
void attachPhysicsWorld(Physics::PhysicsWorld* pw) {physicsWorld = pw;};
void attachPlayerBody(Physics::PhysicsBody* pb1) {playerBody = pb1;};
void update(double dt);
void loadPhysics();
GLuint getTextureShader() {
return shaderTexture;
}
};
#endif