1 USING: arrays kernel math opengl opengl.gl opengl.glu
2 opengl.demo-support ui ui.gadgets ui.render threads accessors
6 TUPLE: nehe4-gadget < gadget rtri rquad thread quit? ;
10 : redraw-interval ( -- dt ) 10 milliseconds ;
12 : <nehe4-gadget> ( -- gadget )
13 nehe4-gadget new-gadget
17 M: nehe4-gadget pref-dim* ( gadget -- dim )
18 drop width height 2array ;
20 M: nehe4-gadget draw-gadget* ( gadget -- )
21 GL_PROJECTION glMatrixMode
23 45.0 width height / >float 0.1 100.0 gluPerspective
24 GL_MODELVIEW glMatrixMode
26 GL_SMOOTH glShadeModel
27 0.0 0.0 0.0 0.0 glClearColor
29 GL_DEPTH_TEST glEnable
31 GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST glHint
32 GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear
34 -1.5 0.0 -6.0 glTranslatef
35 dup rtri>> 0.0 1.0 0.0 glRotatef
39 0.0 1.0 0.0 glVertex3f
41 -1.0 -1.0 0.0 glVertex3f
43 1.0 -1.0 0.0 glVertex3f
48 1.5 0.0 -6.0 glTranslatef
49 dup rquad>> 1.0 0.0 0.0 glRotatef
52 -1.0 1.0 0.0 glVertex3f
53 1.0 1.0 0.0 glVertex3f
54 1.0 -1.0 0.0 glVertex3f
55 -1.0 -1.0 0.0 glVertex3f
58 [ 0.15 - ] change-rquad drop ;
60 : nehe4-update-thread ( gadget -- )
61 dup quit?>> [ drop ] [
67 M: nehe4-gadget graft* ( gadget -- )
69 [ nehe4-update-thread ] curry in-thread ;
71 M: nehe4-gadget ungraft* ( gadget -- )
75 <nehe4-gadget> "NeHe Tutorial 4" open-window ;