1 USING: arrays kernel math opengl opengl.gl opengl.glu
\r
2 opengl.demo-support ui ui.gadgets ui.render threads accessors
\r
6 TUPLE: nehe5-gadget < gadget rtri rquad thread quit? ;
\r
9 : redraw-interval ( -- dt ) 10 milliseconds ;
\r
11 : <nehe5-gadget> ( -- gadget )
\r
12 nehe5-gadget new-gadget
\r
16 M: nehe5-gadget pref-dim* ( gadget -- dim )
\r
17 drop width height 2array ;
\r
19 M: nehe5-gadget draw-gadget* ( gadget -- )
\r
20 GL_PROJECTION glMatrixMode
\r
22 45.0 width height / >float 0.1 100.0 gluPerspective
\r
23 GL_MODELVIEW glMatrixMode
\r
25 GL_SMOOTH glShadeModel
\r
26 0.0 0.0 0.0 0.0 glClearColor
\r
28 GL_DEPTH_TEST glEnable
\r
29 GL_LEQUAL glDepthFunc
\r
30 GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST glHint
\r
31 GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear
\r
33 -1.5 0.0 -6.0 glTranslatef
\r
34 dup rtri>> 0.0 1.0 0.0 glRotatef
\r
37 1.0 0.0 0.0 glColor3f
\r
38 0.0 1.0 0.0 glVertex3f
\r
39 0.0 1.0 0.0 glColor3f
\r
40 -1.0 -1.0 1.0 glVertex3f
\r
41 0.0 0.0 1.0 glColor3f
\r
42 1.0 -1.0 1.0 glVertex3f
\r
44 1.0 0.0 0.0 glColor3f
\r
45 0.0 1.0 0.0 glVertex3f
\r
46 0.0 0.0 1.0 glColor3f
\r
47 1.0 -1.0 1.0 glVertex3f
\r
48 0.0 1.0 0.0 glColor3f
\r
49 1.0 -1.0 -1.0 glVertex3f
\r
51 1.0 0.0 0.0 glColor3f
\r
52 0.0 1.0 0.0 glVertex3f
\r
53 0.0 1.0 0.0 glColor3f
\r
54 1.0 -1.0 -1.0 glVertex3f
\r
55 0.0 0.0 1.0 glColor3f
\r
56 -1.0 -1.0 -1.0 glVertex3f
\r
58 1.0 0.0 0.0 glColor3f
\r
59 0.0 1.0 0.0 glVertex3f
\r
60 0.0 0.0 1.0 glColor3f
\r
61 -1.0 -1.0 -1.0 glVertex3f
\r
62 0.0 1.0 0.0 glColor3f
\r
63 -1.0 -1.0 1.0 glVertex3f
\r
68 1.5 0.0 -7.0 glTranslatef
\r
69 dup rquad>> 1.0 0.0 0.0 glRotatef
\r
71 0.0 1.0 0.0 glColor3f
\r
72 1.0 1.0 -1.0 glVertex3f
\r
73 -1.0 1.0 -1.0 glVertex3f
\r
74 -1.0 1.0 1.0 glVertex3f
\r
75 1.0 1.0 1.0 glVertex3f
\r
77 1.0 0.5 0.0 glColor3f
\r
78 1.0 -1.0 1.0 glVertex3f
\r
79 -1.0 -1.0 1.0 glVertex3f
\r
80 -1.0 -1.0 -1.0 glVertex3f
\r
81 1.0 -1.0 -1.0 glVertex3f
\r
83 1.0 0.0 0.0 glColor3f
\r
84 1.0 1.0 1.0 glVertex3f
\r
85 -1.0 1.0 1.0 glVertex3f
\r
86 -1.0 -1.0 1.0 glVertex3f
\r
87 1.0 -1.0 1.0 glVertex3f
\r
89 1.0 1.0 0.0 glColor3f
\r
90 1.0 -1.0 -1.0 glVertex3f
\r
91 -1.0 -1.0 -1.0 glVertex3f
\r
92 -1.0 1.0 -1.0 glVertex3f
\r
93 1.0 1.0 -1.0 glVertex3f
\r
95 0.0 0.0 1.0 glColor3f
\r
96 -1.0 1.0 1.0 glVertex3f
\r
97 -1.0 1.0 -1.0 glVertex3f
\r
98 -1.0 -1.0 -1.0 glVertex3f
\r
99 -1.0 -1.0 1.0 glVertex3f
\r
101 1.0 0.0 1.0 glColor3f
\r
102 1.0 1.0 -1.0 glVertex3f
\r
103 1.0 1.0 1.0 glVertex3f
\r
104 1.0 -1.0 1.0 glVertex3f
\r
105 1.0 -1.0 -1.0 glVertex3f
\r
107 [ 0.2 + ] change-rtri
\r
108 [ 0.15 - ] change-rquad drop ;
\r
110 : nehe5-update-thread ( gadget -- )
\r
114 redraw-interval sleep
\r
116 nehe5-update-thread
\r
119 M: nehe5-gadget graft* ( gadget -- )
\r
121 [ nehe5-update-thread ] curry in-thread ;
\r
123 M: nehe5-gadget ungraft* ( gadget -- )
\r
128 <nehe5-gadget> "NeHe Tutorial 5" open-window ;
\r