1 USING: accessors calendar kernel literals math
2 opengl.demo-support opengl.gl opengl.glu threads ui ui.gadgets
3 ui.pixel-formats ui.render ;
6 TUPLE: nehe4-gadget < gadget rtri rquad thread quit? ;
10 : redraw-interval ( -- dt ) 10 milliseconds ;
12 : <nehe4-gadget> ( -- gadget )
17 M: nehe4-gadget draw-gadget* ( gadget -- )
18 GL_PROJECTION glMatrixMode
20 45.0 width height / >float 0.1 100.0 gluPerspective
21 GL_MODELVIEW glMatrixMode
23 GL_SMOOTH glShadeModel
24 0.0 0.0 0.0 0.0 glClearColor
26 GL_DEPTH_TEST glEnable
28 GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST glHint
29 GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear
31 -1.5 0.0 -6.0 glTranslatef
32 dup rtri>> 0.0 1.0 0.0 glRotatef
36 0.0 1.0 0.0 glVertex3f
38 -1.0 -1.0 0.0 glVertex3f
40 1.0 -1.0 0.0 glVertex3f
45 1.5 0.0 -6.0 glTranslatef
46 dup rquad>> 1.0 0.0 0.0 glRotatef
49 -1.0 1.0 0.0 glVertex3f
50 1.0 1.0 0.0 glVertex3f
51 1.0 -1.0 0.0 glVertex3f
52 -1.0 -1.0 0.0 glVertex3f
55 [ 0.15 - ] change-rquad drop ;
57 : nehe4-update-thread ( gadget -- )
58 dup quit?>> [ drop ] [
64 M: nehe4-gadget graft* ( gadget -- )
66 [ nehe4-update-thread ] curry in-thread ;
68 M: nehe4-gadget ungraft* ( gadget -- )
73 { title "NeHe Tutorial 4" }
74 { pref-dim { $ width $ height } }
75 { pixel-format-attributes {
78 T{ depth-bits { value 16 } }
81 <nehe4-gadget> >>gadgets ;