-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
535 lines (452 loc) · 19 KB
/
main.cpp
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
// Include standard headers
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <iostream>
// Include GLEW
#include <GL/glew.h>
// Include GLFW
#include <GLFW/glfw3.h>
GLFWwindow* window;
// Include GLM
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
using namespace glm;
#include <utils/controls.hpp>
#include <utils/objloader.hpp>
#include <utils/shader.hpp>
#include <utils/texture.hpp>
int main(){
// Initialise GLFW
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFW\n" );
getchar();
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Open a window and create its OpenGL context
window = glfwCreateWindow( 1280, 720, "Air Hockey", NULL, NULL);
if( window == NULL ){
fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n" );
getchar();
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
// Initialize GLEW
glewExperimental = true; // Needed for core profile
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
getchar();
glfwTerminate();
return -1;
}
// Ensure we can capture the escape key being pressed below
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
// Hide the mouse and enable unlimited mouvement
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
// Set the mouse at the center of the screen
glfwPollEvents();
glfwSetCursorPos(window, 1500/2, 1080/2);
// Dark blue background
glClearColor(0.2f, 0.2f, 0.2f, 0.0f);
// Enable depth test
glEnable(GL_DEPTH_TEST);
// Accept fragment if it closer to the camera than the former one
glDepthFunc(GL_LESS);
// Cull triangles which normal is not towards the camera
glEnable(GL_CULL_FACE);
GLuint VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);
// Create and compile our GLSL program from the shaders
GLuint programID = LoadShaders( "shaders/ColorVertexShader.vertexshader", "shaders/ColorFragmentShader.fragmentshader" );
GLuint programIDTexture = LoadShaders( "shaders/TextureVertexShader.vertexshader", "shaders/TextureFragmentShader.fragmentshader" );
GLuint Texture = loadBMP_custom("textures/Table.bmp");
GLuint TextureID = glGetUniformLocation(programIDTexture, "myTextureSampler");
// Get a handle for our "MVP" uniform
GLuint MatrixID = glGetUniformLocation(programID, "MVP");
GLuint MatrixIDTexture = glGetUniformLocation(programIDTexture, "MVP");
GLuint ViewMatrixID = glGetUniformLocation(programID, "V");
GLuint ViewMatrixIDTexture = glGetUniformLocation(programIDTexture, "V");
GLuint ModelMatrixID = glGetUniformLocation(programID, "M");
GLuint ModelMatrixIDTexture = glGetUniformLocation(programIDTexture, "M");
GLuint LightID = glGetUniformLocation(programID, "LightPosition_worldspace");
GLuint LightIDTexture = glGetUniformLocation(programIDTexture, "LightPosition_worldspace");
std::vector<glm::vec3> table_vertices;
std::vector<glm::vec2> table_uvs;
std::vector<glm::vec3> table_normals;
std::vector<glm::vec3> table_parts_vertices;
std::vector<glm::vec2> table_parts_uvs;
std::vector<glm::vec3> table_parts_normals;
std::vector<glm::vec3> puck_vertices;
std::vector<glm::vec2> puck_uvs;
std::vector<glm::vec3> puck_normals;
std::vector<glm::vec3> striker_neg_vertices;
std::vector<glm::vec2> striker_neg_uvs;
std::vector<glm::vec3> striker_neg_normals;
std::vector<glm::vec3> striker_pos_vertices;
std::vector<glm::vec2> striker_pos_uvs;
std::vector<glm::vec3> striker_pos_normals;
bool res = loadOBJ("objects/table-new.obj", table_vertices, table_uvs, table_normals);
res = loadOBJ("objects/table-parts-new.obj", table_parts_vertices, table_parts_uvs, table_parts_normals);
res = loadOBJ("objects/puck.obj", puck_vertices, puck_uvs, puck_normals);
res = loadOBJ("objects/striker-4.obj", striker_neg_vertices, striker_neg_uvs, striker_neg_normals);
res = loadOBJ("objects/striker4.obj", striker_pos_vertices, striker_pos_uvs, striker_pos_normals);
int table_vertices_size = table_vertices.size();
int table_parts_vertices_size = table_parts_vertices.size();
int puck_vertices_size = puck_vertices.size();
int striker_vertices_size = striker_neg_vertices.size();
GLfloat puck_color_buffer_data[puck_vertices_size*3];
for (int v = 0; v < puck_vertices_size ; v++){
puck_color_buffer_data[3*v+0] = 0.2;
puck_color_buffer_data[3*v+1] = 0.2;
puck_color_buffer_data[3*v+2] = 0.2;
}
GLfloat striker_neg_color_buffer_data[striker_vertices_size*3];
for (int v = 0; v < striker_vertices_size ; v++){
striker_neg_color_buffer_data[3*v+0] = 0.134;
striker_neg_color_buffer_data[3*v+1] = 0.79;
striker_neg_color_buffer_data[3*v+2] = 0;
}
GLfloat striker_pos_color_buffer_data[striker_vertices_size*3];
for (int v = 0; v < striker_vertices_size ; v++){
striker_pos_color_buffer_data[3*v+0] = 0.9;
striker_pos_color_buffer_data[3*v+1] = 0.09;
striker_pos_color_buffer_data[3*v+2] = 0.09;
}
GLfloat table_parts_color_buffer_data[table_parts_vertices_size*3];
for (int v = 0; v < table_parts_vertices_size ; v++){
table_parts_color_buffer_data[3*v+0] = 0.7;
table_parts_color_buffer_data[3*v+1] = 0.7;
table_parts_color_buffer_data[3*v+2] = 0.7;
}
GLuint table_vertex_buffer;
glGenBuffers(1, &table_vertex_buffer);
glBindBuffer(GL_ARRAY_BUFFER, table_vertex_buffer);
glBufferData(GL_ARRAY_BUFFER, table_vertices.size() * sizeof(glm::vec3), &table_vertices[0], GL_STATIC_DRAW);
GLuint table_uvs_buffer;
glGenBuffers(1, &table_uvs_buffer);
glBindBuffer(GL_ARRAY_BUFFER, table_uvs_buffer);
glBufferData(GL_ARRAY_BUFFER, table_uvs.size() * sizeof(glm::vec2), &table_uvs[0], GL_STATIC_DRAW);
GLuint table_normal_buffer;
glGenBuffers(1, &table_normal_buffer);
glBindBuffer(GL_ARRAY_BUFFER, table_normal_buffer);
glBufferData(GL_ARRAY_BUFFER, table_normals.size() * sizeof(glm::vec3), &table_normals[0], GL_STATIC_DRAW);
GLuint table_parts_vertex_buffer;
glGenBuffers(1, &table_parts_vertex_buffer);
glBindBuffer(GL_ARRAY_BUFFER, table_parts_vertex_buffer);
glBufferData(GL_ARRAY_BUFFER, table_parts_vertices.size() * sizeof(glm::vec3), &table_parts_vertices[0], GL_STATIC_DRAW);
GLuint table_parts_normal_buffer;
glGenBuffers(1, &table_parts_normal_buffer);
glBindBuffer(GL_ARRAY_BUFFER, table_parts_normal_buffer);
glBufferData(GL_ARRAY_BUFFER, table_parts_normals.size() * sizeof(glm::vec3), &table_parts_normals[0], GL_STATIC_DRAW);
GLuint puck_vertex_buffer;
glGenBuffers(1, &puck_vertex_buffer);
glBindBuffer(GL_ARRAY_BUFFER, puck_vertex_buffer);
glBufferData(GL_ARRAY_BUFFER, puck_vertices.size() * sizeof(glm::vec3), &puck_vertices[0], GL_STATIC_DRAW);
GLuint puck_normal_buffer;
glGenBuffers(1, &puck_normal_buffer);
glBindBuffer(GL_ARRAY_BUFFER, puck_normal_buffer);
glBufferData(GL_ARRAY_BUFFER, puck_normals.size() * sizeof(glm::vec3), &puck_normals[0], GL_STATIC_DRAW);
GLuint striker_neg_vertex_buffer;
glGenBuffers(1, &striker_neg_vertex_buffer);
glBindBuffer(GL_ARRAY_BUFFER, striker_neg_vertex_buffer);
glBufferData(GL_ARRAY_BUFFER, striker_neg_vertices.size() * sizeof(glm::vec3), &striker_neg_vertices[0], GL_STATIC_DRAW);
GLuint striker_neg_normal_buffer;
glGenBuffers(1, &striker_neg_normal_buffer);
glBindBuffer(GL_ARRAY_BUFFER, striker_neg_normal_buffer);
glBufferData(GL_ARRAY_BUFFER, striker_neg_normals.size() * sizeof(glm::vec3), &striker_neg_normals[0], GL_STATIC_DRAW);
GLuint striker_pos_vertex_buffer;
glGenBuffers(1, &striker_pos_vertex_buffer);
glBindBuffer(GL_ARRAY_BUFFER, striker_pos_vertex_buffer);
glBufferData(GL_ARRAY_BUFFER, striker_pos_vertices.size() * sizeof(glm::vec3), &striker_pos_vertices[0], GL_STATIC_DRAW);
GLuint striker_pos_normal_buffer;
glGenBuffers(1, &striker_pos_normal_buffer);
glBindBuffer(GL_ARRAY_BUFFER, striker_pos_normal_buffer);
glBufferData(GL_ARRAY_BUFFER, striker_pos_normals.size() * sizeof(glm::vec3), &striker_pos_normals[0], GL_STATIC_DRAW);
GLuint puck_color_buffer;
glGenBuffers(1, &puck_color_buffer);
glBindBuffer(GL_ARRAY_BUFFER, puck_color_buffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(puck_color_buffer_data), puck_color_buffer_data, GL_STATIC_DRAW);
GLuint striker_neg_color_buffer;
glGenBuffers(1, &striker_neg_color_buffer);
glBindBuffer(GL_ARRAY_BUFFER, striker_neg_color_buffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(striker_neg_color_buffer_data), striker_neg_color_buffer_data, GL_STATIC_DRAW);
GLuint striker_pos_color_buffer;
glGenBuffers(1, &striker_pos_color_buffer);
glBindBuffer(GL_ARRAY_BUFFER, striker_pos_color_buffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(striker_pos_color_buffer_data), striker_pos_color_buffer_data, GL_STATIC_DRAW);
GLuint table_parts_color_buffer;
glGenBuffers(1, &table_parts_color_buffer);
glBindBuffer(GL_ARRAY_BUFFER, table_parts_color_buffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(table_parts_color_buffer_data), table_parts_color_buffer_data, GL_STATIC_DRAW);
std::cout<<"---------------------------------\n\nGame start:"<< std::endl;
do{
// Clear the screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Use our shader
int status = getGameStatus();
if(status) {
if(status == -1)
std::cout <<"\nRed Wins!!"<< std::endl;
else
std::cout <<"\nGreen Wins!!"<< std::endl;
break;
}
glUseProgram(programIDTexture);
// Compute the MVP matrix from keyboard and mouse input
computeMatricesFromInputs();
glm::mat4 ProjectionMatrix = getProjectionMatrix();
glm::mat4 ViewMatrix = getViewMatrix();
glm::mat4 ModelMatrix = glm::mat4(1.0);
glm::mat4 MVP = ProjectionMatrix * ViewMatrix * ModelMatrix;
// Send our transformation to the currently bound shader,
// in the "MVP" uniform
glUniformMatrix4fv(MatrixIDTexture, 1, GL_FALSE, &MVP[0][0]);
glUniformMatrix4fv(ModelMatrixIDTexture, 1, GL_FALSE, &ModelMatrix[0][0]);
glUniformMatrix4fv(ViewMatrixIDTexture, 1, GL_FALSE, &ViewMatrix[0][0]);
glm::vec3 lightPos = glm::vec3(0,0,7);
glUniform3f(LightIDTexture, lightPos.x, lightPos.y, lightPos.z);
// Bind our texture in Texture Unit 0
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, Texture);
// Set our "myTextureSampler" sampler to use Texture Unit 0
glUniform1i(TextureID, 0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, table_vertex_buffer);
glVertexAttribPointer(
0, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, table_uvs_buffer);
glVertexAttribPointer(
1, // attribute
2, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
glEnableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, table_normal_buffer);
glVertexAttribPointer(
2, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// glPushMatrix();
glDrawArrays(GL_TRIANGLES, 0, table_vertices.size() );
// glPopMatrix();
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(2);
glUseProgram(programID);
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
glUniformMatrix4fv(ModelMatrixID, 1, GL_FALSE, &ModelMatrix[0][0]);
glUniformMatrix4fv(ViewMatrixID, 1, GL_FALSE, &ViewMatrix[0][0]);
glUniform3f(LightID, lightPos.x, lightPos.y, lightPos.z);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, table_parts_vertex_buffer);
glVertexAttribPointer(
0, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, table_parts_color_buffer);
glVertexAttribPointer(
1, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
glEnableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, table_parts_normal_buffer);
glVertexAttribPointer(
2, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// glPushMatrix();
glDrawArrays(GL_TRIANGLES, 0, table_parts_vertices.size() );
// glPopMatrix();
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(2);
std::pair<float, float> puck_trans = getPuckTrans();
ModelMatrix = glm::mat4(1.0);
glm::mat4 myTranslateMatrix = glm::translate(glm::mat4(), glm::vec3(puck_trans.first, puck_trans.second, 0));
ModelMatrix = myTranslateMatrix * ModelMatrix;
MVP = ProjectionMatrix * ViewMatrix * ModelMatrix;
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
glUniformMatrix4fv(ModelMatrixID, 1, GL_FALSE, &ModelMatrix[0][0]);
glUniformMatrix4fv(ViewMatrixID, 1, GL_FALSE, &ViewMatrix[0][0]);
glUniform3f(LightID, lightPos.x, lightPos.y, lightPos.z);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, puck_vertex_buffer);
glVertexAttribPointer(
0, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, puck_color_buffer);
glVertexAttribPointer(
1, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
glEnableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, puck_normal_buffer);
glVertexAttribPointer(
2, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// glPushMatrix();
glDrawArrays(GL_TRIANGLES, 0, puck_vertices.size() );
// glPopMatrix();
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(2);
std::pair<float, float> striker_trans = getStrikerNegTrans();
ModelMatrix = glm::mat4(1.0);
myTranslateMatrix = glm::translate(glm::mat4(), glm::vec3(striker_trans.first, striker_trans.second, 0));
ModelMatrix = myTranslateMatrix * ModelMatrix;
MVP = ProjectionMatrix * ViewMatrix * ModelMatrix;
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
glUniformMatrix4fv(ModelMatrixID, 1, GL_FALSE, &ModelMatrix[0][0]);
glUniformMatrix4fv(ViewMatrixID, 1, GL_FALSE, &ViewMatrix[0][0]);
glUniform3f(LightID, lightPos.x, lightPos.y, lightPos.z);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, striker_neg_vertex_buffer);
glVertexAttribPointer(
0, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, striker_neg_color_buffer);
glVertexAttribPointer(
1, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
glEnableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, striker_neg_normal_buffer);
glVertexAttribPointer(
2, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// glPushMatrix();
glDrawArrays(GL_TRIANGLES, 0, striker_neg_vertices.size() );
// glPopMatrix();
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(2);
striker_trans = getStrikerPosTrans();
ModelMatrix = glm::mat4(1.0);
myTranslateMatrix = glm::translate(glm::mat4(), glm::vec3(striker_trans.first, striker_trans.second, 0));
ModelMatrix = myTranslateMatrix * ModelMatrix;
MVP = ProjectionMatrix * ViewMatrix * ModelMatrix;
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
glUniformMatrix4fv(ModelMatrixID, 1, GL_FALSE, &ModelMatrix[0][0]);
glUniformMatrix4fv(ViewMatrixID, 1, GL_FALSE, &ViewMatrix[0][0]);
glUniform3f(LightID, lightPos.x, lightPos.y, lightPos.z);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, striker_pos_vertex_buffer);
glVertexAttribPointer(
0, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, striker_pos_color_buffer);
glVertexAttribPointer(
1, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
glEnableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, striker_pos_normal_buffer);
glVertexAttribPointer(
2, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// glPushMatrix();
glDrawArrays(GL_TRIANGLES, 0, striker_pos_vertices.size() );
// glPopMatrix();
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(2);
// Swap buffers
glfwSwapBuffers(window);
glfwPollEvents();
// sleep(1);
} // Check if the ESC key was pressed or the window was closed
while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
glfwWindowShouldClose(window) == 0 );
glDeleteBuffers(1, &table_vertex_buffer);
glDeleteBuffers(1, &table_parts_vertex_buffer);
glDeleteBuffers(1, &puck_vertex_buffer);
glDeleteBuffers(1, &striker_neg_vertex_buffer);
glDeleteBuffers(1, &striker_pos_vertex_buffer);
glDeleteBuffers(1, &puck_color_buffer);
glDeleteBuffers(1, &striker_neg_color_buffer);
glDeleteBuffers(1, &striker_pos_color_buffer);
glDeleteProgram(programID);
glDeleteVertexArrays(1, &VertexArrayID);
glfwTerminate();
return 0;
}