-USING: arrays kernel math math.functions math.order math.vectors
-namespaces opengl opengl.gl sequences ui ui.gadgets ui.gestures
-ui.gadgets.worlds ui.render accessors combinators literals ;
+USING: accessors combinators kernel literals math math.functions
+math.order math.vectors namespaces opengl opengl.gl sequences
+ui.gadgets ui.gadgets.worlds ui.gestures ;
IN: opengl.demo-support
CONSTANT: FOV $[ 2.0 sqrt 1 + ]
[ near-plane ] [ far-plane ] [ fov-ratio ] tri [
nip swap FOV / v*n
first2 [ -+ ] bi@
- ] 3keep drop ;
+ ] 2keepd ;
M: demo-world resize-world
GL_PROJECTION glMatrixMode
glLoadIdentity
- [ [ 0 0 ] dip dim>> first2 glViewport ]
+ [ [ { 0 0 } ] dip dim>> gl-viewport ]
[ demo-world-frustum glFrustum ] bi ;
: demo-world-set-matrix ( gadget -- )
- GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear
+ flags{ GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT } glClear
GL_MODELVIEW glMatrixMode
glLoadIdentity
[ [ 0.0 0.0 ] dip distance>> neg glTranslatef ]
over first2 glVertex2d
dup first pick second glVertex2d
dup first2 glVertex2d
- swap first swap second glVertex2d
+ [ first ] [ second ] bi* glVertex2d
] do-state ;
demo-world H{
{ T{ key-down f f "UP" } [ KEY-ROTATE-STEP swap pitch-demo-world ] }
{ T{ key-down f f "=" } [ dup distance-step neg swap zoom-demo-world ] }
{ T{ key-down f f "-" } [ dup distance-step swap zoom-demo-world ] }
-
+
{ T{ button-down f f 1 } [ drop reset-last-drag-rel ] }
{ T{ drag f 1 } [ drag-yaw-pitch rot [ pitch-demo-world ] keep yaw-demo-world ] }
{ mouse-scroll [ scroll-direction get second over distance-step * swap zoom-demo-world ] }
} set-gestures
-