factor/extra/nehe/2/2.factor

44 lines
1.1 KiB
Factor
Raw Normal View History

USING: arrays kernel math opengl opengl.gl opengl.glu
opengl.demo-support ui ui.gadgets ui.render literals accessors ;
2007-09-20 18:09:08 -04:00
IN: nehe.2
2008-07-12 02:29:25 -04:00
TUPLE: nehe2-gadget < gadget ;
2007-09-20 18:09:08 -04:00
CONSTANT: width 256
CONSTANT: height 256
2007-09-20 18:09:08 -04:00
: <nehe2-gadget> ( -- gadget )
nehe2-gadget new ;
2007-09-20 18:09:08 -04:00
M: nehe2-gadget draw-gadget* ( gadget -- )
drop
GL_PROJECTION glMatrixMode
glLoadIdentity
45.0 width height / >float 0.1 100.0 gluPerspective
GL_MODELVIEW glMatrixMode
glLoadIdentity
GL_SMOOTH glShadeModel
0.0 0.0 0.0 0.0 glClearColor
1.0 glClearDepth
GL_DEPTH_TEST glEnable
GL_LEQUAL glDepthFunc
GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST glHint
GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear
glLoadIdentity
-1.5 0.0 -6.0 glTranslatef
GL_TRIANGLES [
0.0 1.0 0.0 glVertex3f
-1.0 -1.0 0.0 glVertex3f
1.0 -1.0 0.0 glVertex3f
] do-state
3.0 0.0 0.0 glTranslatef
GL_QUADS [
-1.0 1.0 0.0 glVertex3f
1.0 1.0 0.0 glVertex3f
1.0 -1.0 0.0 glVertex3f
-1.0 -1.0 0.0 glVertex3f
] do-state ;
MAIN-WINDOW: run2 { { title "NeHe Tutorial 2" } { pref-dim { $ width $ height } } }
<nehe2-gadget> >>gadgets ;