-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChairs.py
81 lines (64 loc) · 1.57 KB
/
Chairs.py
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
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
def init():
glMatrixMode(GL_PROJECTION)
gluPerspective(60, 1, 0.1, 50)
gluLookAt(10, 10, 10, 0, 0, 0, 0, 1, 0)
glClearColor(0, 0, 0, 1)
glClear(GL_COLOR_BUFFER_BIT)
def draw_cube(size, x, y, z):
glPushMatrix()
glPushAttrib(GL_ALL_ATTRIB_BITS)
glMatrixMode(GL_MODELVIEW)
glScale(x, y, z)
glutSolidCube(size)
glPopAttrib()
glPopMatrix()
glLoadIdentity()
def drawChair():
glPushMatrix()
glPushAttrib(GL_ALL_ATTRIB_BITS)
# seat
draw_cube(2, 3, .5, 2)
# Back
glTranslate(2, 2.5, -2.5)
draw_cube(2, 3, 3, .5)
glTranslate(-8, 2.5, -2.5)
draw_cube(2, 3, 3, .5)
# Legs
glTranslate(4, -5, -4.5)
draw_cube(1, .6, 6, .6)
glTranslate(-7, -5, -4)
draw_cube(1, .6, 6, .6)
glTranslate(4, -5, 0)
draw_cube(1, .6, 6, .6)
glTranslate(-7, -5, 0)
draw_cube(1, .6, 6, .6)
glTranslate(-3, -5, 0)
draw_cube(1, .6, 6, .6)
glTranslate(-14, -5, 0)
draw_cube(1, .6, 6, .6)
glTranslate(-3, -5, -4.5)
draw_cube(1, .6, 6, .6)
glTranslate(-14, -5, -4.5)
draw_cube(1, .6, 6, .6)
glPopAttrib()
glPopMatrix()
def drawChairs():
glMatrixMode(GL_MODELVIEW)
glColor3f(0, 1, 1)
glTranslate(-7, 0, 0)
drawChair()
glLoadIdentity()
glTranslate(2, 0, 0)
drawChair()
glLoadIdentity()
glFlush()
glutInit()
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
glutInitWindowSize(600, 600)
glutCreateWindow(b"Chairs")
glutDisplayFunc(drawChairs)
init()
glutMainLoop()