]> gitweb.factorcode.org Git - factor.git/blob - extra/nehe/2/2.factor
factor: remove extra whitespace
[factor.git] / extra / nehe / 2 / 2.factor
1 USING: accessors kernel literals math opengl.demo-support
2 opengl.gl opengl.glu ui ui.gadgets ui.pixel-formats ui.render ;
3 IN: nehe.2
4
5 TUPLE: nehe2-gadget < gadget ;
6
7 CONSTANT: width 256
8 CONSTANT: height 256
9
10 : <nehe2-gadget> ( -- gadget )
11     nehe2-gadget new ;
12
13 M: nehe2-gadget draw-gadget* ( gadget -- )
14     drop
15     GL_PROJECTION glMatrixMode
16     glLoadIdentity
17     45.0 width height / >float 0.1 100.0 gluPerspective
18     GL_MODELVIEW glMatrixMode
19     glLoadIdentity
20     GL_SMOOTH glShadeModel
21     0.0 0.0 0.0 0.0 glClearColor
22     1.0 glClearDepth
23     GL_DEPTH_TEST glEnable
24     GL_LEQUAL glDepthFunc
25     GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST glHint
26     GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear
27     glLoadIdentity
28     -1.5 0.0 -6.0 glTranslatef
29     GL_TRIANGLES [
30         0.0 1.0 0.0 glVertex3f
31         -1.0 -1.0 0.0 glVertex3f
32         1.0 -1.0 0.0 glVertex3f
33     ] do-state
34     3.0 0.0 0.0 glTranslatef
35     GL_QUADS [
36         -1.0 1.0 0.0 glVertex3f
37         1.0 1.0 0.0 glVertex3f
38         1.0 -1.0 0.0 glVertex3f
39         -1.0 -1.0 0.0 glVertex3f
40     ] do-state ;
41
42 MAIN-WINDOW: run2
43     {
44         { title "NeHe Tutorial 2" }
45         { pref-dim { $ width $ height } }
46         { pixel-format-attributes {
47             windowed
48             double-buffered
49             T{ depth-bits { value 16 } }
50         } }
51     }
52     <nehe2-gadget> >>gadgets ;