-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.cpp
521 lines (461 loc) · 20.7 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
#include "../common/util.h"
#include "../common/shader.h"
#include "../common/camera.h"
#include "mesh.h"
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#define WIDTH (640 * 2)
#define HEIGHT (480 * 2)
#define NUM_ASTEROIDS 2000
#define NUM_POINT_LIGHTS 32
#define SEED 1993
const char* VERTEX_GEOM_SRC = "#version 330 core\n"
"layout(location=0) in vec3 position;"
"layout(location=1) in vec3 normal;"
"layout(location=2) in vec2 texCoord;"
"layout(location=3) in mat4 model_inst;"
"uniform mat4 view;"
"uniform mat4 projection;"
"uniform float specularPower;"
"out vec3 fPosition;"
"out vec3 fNormal;"
"out vec2 fTexCoord;"
"out float fSpecularPower;"
"void main()"
"{"
" vec4 wP = model_inst * vec4(position, 1.0);"
" fPosition = wP.xyz;"
" gl_Position = projection * view * wP;"
" fNormal = transpose(inverse(mat3(model_inst))) * normal;"
" fTexCoord = texCoord;"
" fSpecularPower = specularPower;"
"}";
const char* FRAGMENT_GEOM_SRC = "#version 330 core\n"
"layout(location=0) out vec3 g_position;"
"layout(location=1) out vec4 g_normal_spec_pow;" // rgb: normal, a: specular power
"layout(location=2) out vec4 g_albedo_spec;" // rgb: albedo, a: spec
"in vec3 fPosition;"
"in vec3 fNormal;"
"in vec2 fTexCoord;"
"in float fSpecularPower;"
"uniform sampler2D diffuse;"
"uniform sampler2D specular;"
"void main()"
"{"
" g_position = fPosition;"
" g_normal_spec_pow.rgb = normalize(fNormal);"
" g_normal_spec_pow.a = fSpecularPower;"
" g_albedo_spec = texture(diffuse, fTexCoord);"
" g_albedo_spec.a = texture(specular, fTexCoord).r;"
"}";
const char* VERTEX_LIGHT_SRC = "#version 330 core\n"
"layout(location=0) in vec2 position;"
"layout(location=1) in vec2 texCoord;"
"out vec2 fTexCoord;"
"void main()"
"{"
" gl_Position = vec4(position, 0.0, 1.0);"
" fTexCoord = texCoord;"
"}";
const char* FRAGMENT_LIGHT_SRC = "#version 330 core\n"
"#define NUM_POINT_LIGHTS 32\n"
"struct PointLight"
"{"
" vec3 position;"
" vec3 att;" // x = constant, y = linear, z = quadratic
" vec3 ambient;"
" vec3 diffuse;"
" vec3 specular;"
"};"
"in vec2 fTexCoord;"
"uniform PointLight lights[NUM_POINT_LIGHTS];"
"uniform vec3 eye;"
"uniform sampler2D g_position;"
"uniform sampler2D g_normal_spec_pow;"
"uniform sampler2D g_albedo_spec;"
"out vec4 outputColor;"
"vec3 pointLight(PointLight light, vec3 normal, vec3 pos, vec3 eye, vec3 albedo, float pSpecular, float specularPower)"
"{"
" vec3 dir = normalize(light.position - pos);"
" vec3 ambient = albedo * light.ambient;"
" vec3 diffuse = max(dot(normal, dir), 0.0) * albedo * light.diffuse;"
" vec3 hwd = normalize(dir + eye);"
" float spec = pow(max(dot(normal, hwd), 0.0), specularPower);"
" vec3 specular = light.specular * spec * pSpecular;"
" float dist = length(light.position - pos);"
" float attenuation = 1.0f / (light.att.x + light.att.y * dist + light.att.z * dist * dist);"
" return (ambient + diffuse + specular) * attenuation;"
"}"
"void main()"
"{"
" vec3 fPosition = texture(g_position, fTexCoord).rgb;"
" vec3 fNormal = texture(g_normal_spec_pow, fTexCoord).rgb;"
" float specularPower = texture(g_normal_spec_pow, fTexCoord).a;"
" vec3 albedo = texture(g_albedo_spec, fTexCoord).rgb;"
" float specular = texture(g_albedo_spec, fTexCoord).a;"
" vec3 eyeDir = normalize(eye - fPosition);"
" vec3 result = vec3(0.0);"
" for(int i = 0; i < NUM_POINT_LIGHTS; ++i)"
" {"
" result += pointLight(lights[i], fNormal, fPosition, eyeDir, albedo, specular, specularPower);"
" }"
" outputColor = vec4(result, 1.0);"
"}";
// NEW: HDR SHADER
const char* VERTEX_HDR_SRC = VERTEX_LIGHT_SRC;
const char* FRAGMENT_HDR_SRC = "#version 330 core\n"
"in vec2 fTexCoord;"
"out vec4 hdrColor;"
"uniform sampler2D hdrBuff;"
"void main()"
"{"
" vec3 hdrResult = texture(hdrBuff, fTexCoord).rgb;"
" vec3 result = vec3(1.0) - exp(-hdrResult * 0.5);"
" hdrColor = vec4(result, 1.0);"
"}";
// END NEW
/*
* Multiple render targets!
* We create a frame buffer with several GL_COLOR_ATTACHMENTs,
* which allows us to render to multiple textures at once
*/
struct GBuffer
{
GBuffer()
{
// Generate a framebuffer
glGenFramebuffers(1, &buffer);
glBindFramebuffer(GL_FRAMEBUFFER, buffer);
// Create a texture for the position buffer
glGenTextures(1, &position);
glBindTexture(GL_TEXTURE_2D, position);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, WIDTH, HEIGHT, 0, GL_RGB, GL_FLOAT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// Bind the position buffer to the framebuffer
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, position, 0);
// Create a texture for the normal buffer
glGenTextures(1, &normal);
glBindTexture(GL_TEXTURE_2D, normal);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_FLOAT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// Bind the normal buffer to the framebuffer
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, normal, 0);
// Create a texture for the color buffer
glGenTextures(1, &color);
glBindTexture(GL_TEXTURE_2D, color);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_FLOAT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// Bind the color buffer to the framebuffer
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, color, 0);
GLuint colorAttachments[] =
{
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2
};
glDrawBuffers(3, colorAttachments);
// Create a depth buffer
glGenRenderbuffers(1, &depth);
glBindRenderbuffer(GL_RENDERBUFFER, depth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, WIDTH, HEIGHT);
// Bind the depth buffer to the framebuffer
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth);
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
std::cerr << "Could not create G-Buffer!" << std::endl
<< "Error number: " << glGetError() << std::endl;
exit(1);
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
};
~GBuffer()
{
// or glDeleteTextures(3, &position);
glDeleteTextures(1, &position);
glDeleteTextures(1, &normal);
glDeleteTextures(1, &color);
glDeleteRenderbuffers(1, &depth);
glDeleteFramebuffers(1, &buffer);
};
GLuint buffer, position, normal, color, depth;
};
struct PointLight
{
void set(const glm::vec3& position, const glm::vec3& att, const glm::vec3& ambient,
const glm::vec3& diffuse, const glm::vec3& specular)
{
this->position = position;
this->att = att;
this->ambient = ambient;
this->diffuse = diffuse;
this->specular = specular;
};
void setUniforms(int index, GLuint program)
{
std::string array = "lights[" + std::to_string(index) + "].";
glUniform3fv(glGetUniformLocation(program, (array + "position").c_str()), 1, glm::value_ptr(position));
glUniform3fv(glGetUniformLocation(program, (array + "att").c_str()), 1, glm::value_ptr(att));
glUniform3fv(glGetUniformLocation(program, (array + "ambient").c_str()), 1, glm::value_ptr(ambient));
glUniform3fv(glGetUniformLocation(program, (array + "diffuse").c_str()), 1, glm::value_ptr(diffuse));
glUniform3fv(glGetUniformLocation(program, (array + "specular").c_str()), 1, glm::value_ptr(specular));
};
private:
glm::vec3 position;
glm::vec3 att;
glm::vec3 ambient;
glm::vec3 diffuse;
glm::vec3 specular;
};
int main(void)
{
GLFWwindow* window;
window = init("HDR", WIDTH / 2, HEIGHT / 2);
if(!window)
{
return -1;
}
glEnable(GL_DEPTH_TEST);
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
Camera camera(CAMERA_PERSPECTIVE, 45.0f, 0.1f, 1000.0f, (float)WIDTH, (float)HEIGHT);
setCamera(&camera);
GLuint geomProgram, lightProgram, hdrProgram;
{
// Geometry pass program
GLuint vertex = createShader(VERTEX_GEOM_SRC, GL_VERTEX_SHADER);
GLuint fragment = createShader(FRAGMENT_GEOM_SRC, GL_FRAGMENT_SHADER);
geomProgram = createShaderProgram(vertex, fragment);
linkShader(geomProgram);
validateShader(geomProgram);
glDetachShader(geomProgram, vertex);
glDeleteShader(vertex);
glDetachShader(geomProgram, fragment);
glDeleteShader(fragment);
}
{
// Light pass program
GLuint vertex = createShader(VERTEX_LIGHT_SRC, GL_VERTEX_SHADER);
GLuint fragment = createShader(FRAGMENT_LIGHT_SRC, GL_FRAGMENT_SHADER);
lightProgram = createShaderProgram(vertex, fragment);
linkShader(lightProgram);
validateShader(lightProgram);
glDetachShader(lightProgram, vertex);
glDeleteShader(vertex);
glDetachShader(lightProgram, fragment);
glDeleteShader(fragment);
}
{
// HDR program
GLuint vertex = createShader(VERTEX_HDR_SRC, GL_VERTEX_SHADER);
GLuint fragment = createShader(FRAGMENT_HDR_SRC, GL_FRAGMENT_SHADER);
hdrProgram = createShaderProgram(vertex, fragment);
linkShader(hdrProgram);
validateShader(hdrProgram);
glDetachShader(hdrProgram, vertex);
glDeleteShader(vertex);
glDetachShader(hdrProgram, fragment);
glDeleteShader(fragment);
}
// Create quad VAO
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
GLuint vbo;
glGenBuffers(1, &vbo);
float vertices[] =
{
// x y u v
-1.0f, 1.0f, 0.0f, 0.0f,
1.0f, 1.0f, 1.0f, 0.0f,
1.0f, -1.0f, 1.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 1.0f
};
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
GLuint ebo;
glGenBuffers(1, &ebo);
GLuint indices[] =
{
0, 1, 2,
2, 3, 0
};
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), 0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (void*)(2 * sizeof(GLfloat)));
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
// Load the diffuse and specular texture
glUseProgram(geomProgram);
int w, h;
GLuint textureDiff = loadImage("asteroid.png", &w, &h, 0, false); // GL_TEXTURE0
if(!textureDiff)
{
return -1;
}
glUniform1i(glGetUniformLocation(geomProgram, "diffuse"), 0); // GL_TEXTURE0
GLuint textureSpec = loadImage("asteroid.png", &w, &h, 1, false); // GL_TEXTURE1
if(!textureSpec)
{
return -1;
}
glUniform1i(glGetUniformLocation(geomProgram, "specular"), 1); // GL_TEXTURE1
Mesh mesh;
if(!mesh.load("asteroid.obj"))
{
std::cerr << "Could not load mesh" << std::endl;
return -1;
}
// Set random positions for the asteroids
std::vector<glm::mat4> models;
models.resize(NUM_ASTEROIDS);
srand(SEED);
for(int i = 0; i < NUM_ASTEROIDS; ++i)
{
glm::mat4 model;
// Translate
model = glm::translate(model, glm::vec3(rand() % 100 - 50.0f, rand() % 100 - 50.0f, rand() % 100));
// Scale
float scale = (rand() % 200) / 100.0f + 0.1f;
model = glm::scale(model, glm::vec3(scale, scale, scale));
// Rotate
model = glm::rotate(model, glm::radians((float)(rand() % 100)), glm::vec3(1.0f, 1.0f, 1.0f));
models[i] = model;
}
mesh.setInstances(NUM_ASTEROIDS, models);
// Set positions and more for the lights
PointLight lights[NUM_POINT_LIGHTS];
for(int i = 0; i < NUM_POINT_LIGHTS - 1; ++i)
{
float x, y, z;
x = rand() % 100 - 50.0f;
y = rand() % 100 - 50.0f;
z = rand() % 100;
float r, g, b; // For simplicity's sake, ambient, diffuse and specular colours are the same
r = ((rand() % 10) / 20.0f) + 0.5;
g = ((rand() % 10) / 20.0f) + 0.5;
b = ((rand() % 10) / 20.0f) + 0.5;
float con, lin, qua;
con = 1.0f;
lin = 0.09f;
qua = 0.032f;
lights[i].set(glm::vec3(x, y, z), glm::vec3(con, lin, qua), glm::vec3(r, g, b),
glm::vec3(r, g, b), glm::vec3(r, g, b));
}
// NEW: We also create one very bright light (a star, like the sun, for example)
float con, lin, qua;
con = 1.0f;
lin = 0.09f;
qua = 0.032f;
glm::vec3 rgb(20.0f, 20.0f, 20.0f);
lights[NUM_POINT_LIGHTS - 1].set(
glm::vec3(20.0f, 20.0f, 20.0f),
glm::vec3(con, lin, qua),
rgb, rgb, rgb);
// END NEW
// NEW: Set up a framebuffer for HDR rendering
GLuint depthBuff;
glGenRenderbuffers(1, &depthBuff);
glBindRenderbuffer(GL_RENDERBUFFER, depthBuff);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, WIDTH, HEIGHT);
GLuint hdrFbo;
glGenFramebuffers(1, &hdrFbo);
GLuint hdrBuff;
glGenTextures(1, &hdrBuff);
glBindTexture(GL_TEXTURE_2D, hdrBuff);
// GL_FLOAT indicates that we can go outside the range of [0.0, 1.0]
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, WIDTH, HEIGHT, 0, GL_RGB, GL_FLOAT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindFramebuffer(GL_FRAMEBUFFER, hdrFbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, hdrBuff, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBuff);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
std::cerr << "Could not create HDR Framebuffer!" << std::endl
<< "Error number: " << glGetError() << std::endl;
exit(1);
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// END NEW
GBuffer gBuffer;
glUseProgram(lightProgram);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, gBuffer.position);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, gBuffer.normal);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, gBuffer.color);
glUniform1i(glGetUniformLocation(lightProgram, "g_position"), 0);
glUniform1i(glGetUniformLocation(lightProgram, "g_normal_spec_pow"), 1);
glUniform1i(glGetUniformLocation(lightProgram, "g_albedo_spec"), 2);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
while(!glfwWindowShouldClose(window))
{
if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
{
break;
}
updateCamera(WIDTH, HEIGHT, window);
// GEOMETRY PASS
glBindFramebuffer(GL_FRAMEBUFFER, gBuffer.buffer);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glm::mat4 proj = camera.getProjection();
glm::mat4 view = camera.getView();
glUseProgram(geomProgram);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureDiff);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, textureSpec);
glUniformMatrix4fv(glGetUniformLocation(geomProgram, "projection"), 1, GL_FALSE, glm::value_ptr(proj));
glUniformMatrix4fv(glGetUniformLocation(geomProgram, "view"), 1, GL_FALSE, glm::value_ptr(view));
glUniform1f(glGetUniformLocation(geomProgram, "specularPower"), 16.0f);
mesh.render();
// LIGHT PASS
// NEW: We now render to the HDR buffer instead of the screen
glBindFramebuffer(GL_FRAMEBUFFER, hdrFbo);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// END NEW
glUseProgram(lightProgram);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, gBuffer.position);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, gBuffer.normal);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, gBuffer.color);
glUniform3fv(glGetUniformLocation(lightProgram, "eye"), 1, glm::value_ptr(camera.getPosition()));
for(int i = 0; i < NUM_POINT_LIGHTS; ++i)
{
lights[i].setUniforms(i, lightProgram);
}
glBindVertexArray(vao);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
// NEW: HDR PASS -> Now render the resulting quad to the screen
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(hdrProgram);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, hdrBuff); // We drew to the HDR FBO in the previous pass
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
// END NEW
glBindVertexArray(0);
glfwSwapBuffers(window);
glfwPollEvents();
}
// Clean up
glDeleteTextures(1, &textureDiff);
glDeleteTextures(1, &textureSpec);
glDeleteProgram(geomProgram);
glDeleteProgram(lightProgram);
glDeleteVertexArrays(1, &vao);
glDeleteBuffers(1, &vbo);
glDeleteBuffers(1, &ebo);
glfwTerminate();
return 0;
}