Hello Slava,
Is this code better? You say that one usually doesn't need to change the
projection or model matrices but isn't that necessary here. Any
suggestions or criticism you have time for are welcome. Thanks for the help.
USING: kernel gadgets gadgets-theme opengl arrays timers math sequences ;
IN: red-book
: rotate-square ( angle -- )
0.0 0.0 1.0 glRotatef ;
: draw-square ( -- )
{ 1.0 1.0 1.0 1.0 } gl-color
{ -25.0 -25.0 } { 25.0 25.0 } gl-fill-rect ;
: update-rotation ( angle -- angle )
2.0 + dup 360.0 > [ 360.0 - ] when ;
TUPLE: square-gadget rotation ;
C: square-gadget ( -- gadget )
[ 0.0 swap set-square-gadget-rotation ] keep
[ delegate>gadget ] keep ;
M: square-gadget pref-dim* ( gadget -- dim )
drop { 250 250 } ;
M: square-gadget draw-gadget* ( gadget -- )
GL_PROJECTION
[
-50.0 50.0 -50.0 50.0 -1.0 1.0 glOrtho
GL_MODELVIEW
[
glLoadIdentity
square-gadget-rotation rotate-square
draw-square
] do-matrix
] do-matrix ;
M: square-gadget tick ( gadget -- )
dup square-gadget-rotation update-rotation
over set-square-gadget-rotation
relayout-1 ;
M: square-gadget graft* ( gadget -- )
black solid-interior ;
square-gadget H{
{ T{ button-down f f 1 } [ dup remove-timer 1 1 add-timer ] }
{ T{ button-down f f 2 } [ remove-timer ] }
} set-gestures
: run-example-1-3 ( -- )
<square-gadget> "Example 1-3" open-window ;
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk