Add ui.gadgets.cartesian

db4
Eduardo Cavazos 2008-07-29 19:37:24 -05:00
parent aaae3ba56f
commit 95b097789c
1 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,50 @@
USING: kernel combinators opengl.gl
ui.render ui.gadgets ui.gadgets.slate
accessors ;
IN: ui.gadgets.cartesian
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: init-slate ( slate -- slate )
init-gadget
[ ] >>action
{ 200 200 } >>pdim
[ ] >>graft
[ ] >>ungraft ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
TUPLE: cartesian < slate x-min x-max y-min y-max z-min z-max perspective ;
: init-cartesian ( cartesian -- cartesian )
init-slate
-10 >>x-min
10 >>x-max
-10 >>y-min
10 >>y-max
-1 >>z-min
1 >>z-max ;
: <cartesian> ( -- cartesian ) cartesian new init-cartesian ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
M: cartesian draw-gadget* ( cartesian -- )
GL_PROJECTION glMatrixMode
glLoadIdentity
dup
{
[ x-min>> ] [ x-max>> ]
[ y-min>> ] [ y-max>> ]
[ z-min>> ] [ z-max>> ]
}
cleave
glOrtho
GL_MODELVIEW glMatrixMode
glLoadIdentity
call-next-method ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!