-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhut.cpp
More file actions
83 lines (75 loc) · 1.29 KB
/
hut.cpp
File metadata and controls
83 lines (75 loc) · 1.29 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
#include <GL/glut.h>
GLfloat t,u=1;
void line_join(float x1, float y1, float x2, float y2)
{
glBegin(GL_LINES);
glVertex2f(x1,y1);
glVertex2f(x2,y2);
}
void display()
{
glClearColor(0,0,0,0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,100,0,100);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0,0.7,0.7);
glLineWidth(5);
glColor3f(t,u,0.0);
glBegin(GL_LINES);
line_join(50,80,40,60);
line_join(50,80,60,60);
line_join(40,60,60,60);
line_join(40,60,40,30);
line_join(60,60,60,30);
line_join(40,30,60,30);
line_join(45,30,45,45);
line_join(55,30,55,45);
line_join(45,45,55,45);
glEnd();
glFlush();
}
void key(unsigned char button,int x, int y)
{
if(button=='s','a','d')
{ t=0;
u=1;
}
else if(button=='q','w','e')
{ t=1;
u=0;
}
else{
}
glutPostRedisplay();
}
void mouse(int button,int state,int x, int y)
{
if(button==GLUT_LEFT_BUTTON)
{
t=0;
u=1;
}
else if(button==GLUT_RIGHT_BUTTON)
{
t=1;
u=0;
}
else{
}
glutPostRedisplay();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(500, 500);
glutInitWindowPosition(200, 200);
glutCreateWindow("Hut Color Change");
//init();
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutMouseFunc(mouse);
glutMainLoop();
return 0;
}