-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
90 lines (76 loc) · 2.09 KB
/
test.cpp
File metadata and controls
90 lines (76 loc) · 2.09 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "include/four.h"
vec5 tri[3] = {
vec5(0.0f, 0.0f, -0.1f, 0.0f, 1.0f),
vec5(1.0f, 0.0f, -0.1f, 0.0f, 1.0f),
vec5(0.0f, 1.0f, -0.1f, 0.0f, 1.0f)
};
vec5 pcVerts[5] = {
vec5(0.0f, 0.5f, 0.0f, 0.0f, 1.0f), //0
vec5(-0.5f, 0.0f, 0.0f, 0.0f, 1.0f), //1
vec5(0.5f, 0.0f, 0.0f, 0.0f, 1.0f), //2
vec5(0.0f, 0.0f, -0.5f, 0.0f, 1.0f), //3
vec5(0.0f, 0.0f, 0.0f, -0.5f, 1.0f) //4
};
unsigned int pcInds[30] = {
0, 1, 2,
3, 1, 2,
3, 0, 1,
3, 0, 2,
4, 0, 1,
4, 0, 2,
4, 0, 3,
4, 1, 2,
4, 1, 3,
4, 2, 3
};
glm::vec4 triColors[3] = {
glm::vec4(1.0f, 0.0f, 0.0f, 1.0f),
glm::vec4(0.0f, 1.0f, 0.0f, 1.0f),
glm::vec4(0.0f, 0.0f, 1.0f, 1.0f)
};
int main(int argc, char* argv[]){
Window w;
w.create();
//use GL_LINE_STRIP instead of GL_LINES
w.setUseLineStrip(true);
Camera c;
c.create();
w.setActiveCamera(&c);
Object o;
o.create(&pcVerts[0], 5, &pcInds[0], 30);
//o.setUniformColor(glm::vec4(1.0f, 0.0f, 1.0f, 1.0f));
w.addToScene(&o);
Object o2;
o2.create(&tri[0], 3);
o2.setCustomColor(&triColors[0], 3);
w.addToScene(&o2);
w.setRenderMode(Window::RENDER_WIREFRAME);
while(!w.shouldClose()){
w.clear(0.1f, 0.2f, 0.3f);
o.translate(0.0f, sin(glfwGetTime())/100.0f, 0.0f, 0.0f);
w.update();
if(w.getKeyPress(SDL_SCANCODE_ESCAPE)){
w.setShouldClose(true);
}
if(w.getKeyPress(SDL_SCANCODE_W)){
o.scale(glm::vec4(1.1f, 1.1f, 1.1f, 1.1f));
}
if(w.getKeyPress(SDL_SCANCODE_S)){
o.scale(glm::vec4(0.9f, 0.9f, 0.9f, 0.9f));
}
if(w.getKeyPress(SDL_SCANCODE_A)){
o.rotate(Object::YW_PLANE, -0.1f);
}
if(w.getKeyPress(SDL_SCANCODE_D)){
o.rotate(Object::YW_PLANE, 0.1f);
}
if(w.getKeyPress(SDL_SCANCODE_LCTRL)){
w.setRenderMode(Window::RENDER_WIREFRAME);
}
if(w.getKeyPress(SDL_SCANCODE_LSHIFT)){
w.setRenderMode(Window::RENDER_SOLID);
}
}
w.close();
return 0;
}