-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab6.cpp
67 lines (53 loc) · 1.34 KB
/
Lab6.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
// Lab6 12171788 박지은
#include <gl/glut.h>
#include <gl/freeglut.h>
#include <stdio.h>
void init(void) {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}
void resize(int width, int height) {
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, (double)width / (double)height, 10, 500);
glMatrixMode(GL_MODELVIEW);
}
void draw_axis(void) {
glLineWidth(3); // 좌표축 두께
glBegin(GL_LINES);
glColor3f(1, 0, 0); // x축
glVertex3f(0, 0, 0);
glVertex3f(4, 0, 0);
glColor3f(0, 1, 0); // y축
glVertex3f(0, 0, 0);
glVertex3f(0, 4, 0);
glColor3f(0, 0, 1); // z축
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 4);
glEnd();
glLineWidth(1);
}
void draw(void) {
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0, -20, -10, 0, 0, 0, 0, 1, 0);
glColor3f(1, 1, 0);
glutWireTeapot(4);
draw_axis();
glutSwapBuffers();
// back buffer를 front buffer로 변경
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
// double buffer로 변경
glutInitWindowSize(500, 500);
glutInitWindowPosition(100, 100);
glutCreateWindow("12171788 박지은");
init();
glutDisplayFunc(draw);
glutReshapeFunc(&resize);
glutMainLoop();
return 0;
}