-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
77 lines (60 loc) · 1.51 KB
/
main.cpp
File metadata and controls
77 lines (60 loc) · 1.51 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
// Author: Quentin Lurkin
#include "Application.h"
#include "Table.h"
#include "Triangle.h"
#include "Object.h"
#include "Program.h"
#include <iostream>
using namespace std;
class MyApplication : public Application
{
private:
Triangle *triangle;
Object *root;
Program *program;
public:
void setup()
{
GLuint vertex_shader, fragment_shader;
GLint view_location;
// Chargement des shaders
fragment_shader = loadShader("shader.frag", GL_FRAGMENT_SHADER);
vertex_shader = loadShader("shader.vert", GL_VERTEX_SHADER);
// Creation du pipeline
program = new Program(vertex_shader, fragment_shader);
// Create a Mesh instance
triangle = new Triangle(program);
// Create an Object
root = new Object(triangle, vec3(0, 0, 0), mat4::identity());
}
void update()
{
// Update rotation of the object
//root->setRotation(rotate((float) glfwGetTime()*20, 0.0f, 0.0f, 1.0f));
triangle->update();
}
void render()
{
mat4 projection, view, model;
// Création des matrice View et Projection
float ratio;
ratio = getWidth() / (float) getHeight();
projection = perspective(30.f, ratio, 0.1f, 10);
view = lookat(vec3(0, -2, 2), vec3(0, 0, 0), vec3(0, 0, 1));
model = mat4::identity();
setProjection(projection);
setView(view);
root->render(model);
}
void teardown()
{
delete root;
delete triangle;
delete program;
}
};
int main(void)
{
return MyApplication().run();
}
//TODO: GL Error managment, Object séparation, Log, Exception, Renderable, Updatable, Object Tree, Check comment