-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
66 lines (47 loc) · 1.72 KB
/
Main.cpp
File metadata and controls
66 lines (47 loc) · 1.72 KB
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
#include "Renderer.h"
#include "Shaders.h"
#include "Mesh.h"
#include "FreeCamera/FreeCamera3D.h"
#define GLM_ENABLE_EXPERIMENTAL
#include "../vendor/glm/glm/gtx/euler_angles.hpp"
int main(){
CW::Renderer::Renderer window;
window.setWindowTitle("Mesh Creation and Loading");
CW::Renderer::FreeCamera3D camera(&window);
window.setCursorVisibility(false);
CW::Renderer::Shader shader(Shader::vertex, Shader::fragment);
CW::Renderer::Uniform uniform;
shader.getUniforms().emplace_back(&uniform);
CW::Renderer::Mesh square;
square.addVertices(Mesh::vertices, 4, 0);
square.addIndices(Mesh::indicies);
square.setData<GLfloat>(Mesh::colors, 3, 1, GL_FLOAT);
float time = 0.0f;
float cursor_visible_lock = 0.0f;
bool cursor_lock = true;
while(!window.getWindowData()->should_close){
window.beginFrame();
time += window.getWindowData()->delta_time;
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0f, 0.0f, 1.0f));
model = model * glm::eulerAngleXYZ(0.0f, time, 0.0f);
model = glm::scale(model, glm::vec3(0.1f));
glm::mat4 mvp = camera.transformation(&window) * model;
uniform["transformation"]->set<glm::mat4>(mvp);
if(cursor_lock) window.setCursorOn(true);
else window.setCursorOn(false);
if(window.getInputData()->is_key_down("ESC") && cursor_visible_lock <= 0.0f) {
cursor_lock = !cursor_lock;
cursor_visible_lock = 0.5f;
camera.resetMouse();
}
else if(cursor_visible_lock > 0.0f) cursor_visible_lock -= window.getWindowData()->delta_time;
if(!cursor_lock) camera.event(&window);
shader.bind();
square.render();
shader.unbind();
window.windowEvents();
window.swapBuffer();
};
return 0;
}