-
Notifications
You must be signed in to change notification settings - Fork 20
/
House.cpp
68 lines (68 loc) · 1.38 KB
/
House.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
68
// House
#include<GL\glut.h>
void init(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0, 200.0, 0.0, 150.0);
}
void buildHouse(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.5, 0.5, 0.0);
glBegin(GL_POLYGON);
//start house
glColor3f(1.0, 0.0, 0.0);
glVertex2i(30, 20);
glVertex2i(30, 100);
glVertex2i(170, 100);
glVertex2i(170, 20);
glEnd();
//end house
glBegin(GL_POLYGON);
//start window
glColor3f(1.0, 1.0, 1.0);
glVertex2i(60, 80);
glVertex2i(80, 80);
glVertex2i(80, 65);
glVertex2i(60, 65);
glEnd();
//end window
glBegin(GL_POLYGON);
//start window
glColor3f(1.0, 1.0, 1.0);
glVertex2i(120, 80);
glVertex2i(140, 80);
glVertex2i(140, 65);
glVertex2i(120, 65);
glEnd();
//end window
glBegin(GL_POLYGON);
//start ceiling
glColor3f(1.0, 1.0, 0.0);
glVertex2i(30, 100);
glVertex2i(170, 100);
glVertex2i(100, 130);
glEnd();
//end ceiling
glBegin(GL_POLYGON);
//start door
glColor3f(0.0, 0.5, 1.0);
glVertex2i(80, 21);
glVertex2i(80, 50);
glVertex2i(120, 50);
glVertex2i(120, 21);
glEnd(); //end door
glFlush();
}
void main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(50, 100);
glutInitWindowSize(500, 500);
glutCreateWindow("House OpenGL");
init();
glutDisplayFunc(buildHouse);
glutMainLoop();
}