-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
59 lines (49 loc) · 1.26 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
#include <iostream>
#include <Eigen/Core>
#include <Eigen/LU>
#include "OBJLoader.h"
#include <GLUT/glut.h>
static int win_w = 400 ,win_h = 400;
static Object obj("../cube.obj");
void display() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, win_w, win_h);
gluPerspective(50.0,
static_cast<double>(win_w)/static_cast<double>(win_h),
0.1, 100.0);
gluLookAt(0,0,-10, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glColor3f(0,0,0);
obj.Render();
glutSwapBuffers();
}
void resize(int w,int h) {
win_w = w;
win_h = h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, win_w, win_h);
gluPerspective(50.0,
static_cast<double>(win_w)/static_cast<double>(win_h),
0.1, 100.0);
gluLookAt(0,0,-10, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int main(int argc,char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowPosition(0, 0);
glutInitWindowSize(win_w, win_h);
glutCreateWindow("Home Work 3");
glutDisplayFunc(display);
glutReshapeFunc(resize);
glutMainLoop();
return 0;
}