Merge branch 'master' of git://factorcode.org/git/factor

db4
Doug Coleman 2008-07-31 21:53:35 -05:00
commit 2144fd9abc
4 changed files with 102 additions and 18 deletions
extra
springies/ui
ui/gadgets

View File

@ -23,7 +23,9 @@ IN: springies.ui
GL_MODELVIEW glMatrixMode
glLoadIdentity ;
: display ( -- ) set-projection black gl-color draw-nodes draw-springs ;
! : display ( -- ) set-projection black gl-color draw-nodes draw-springs ;
: display ( -- ) set-projection black set-color draw-nodes draw-springs ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

View File

@ -22,20 +22,15 @@ TUPLE: cartesian < slate x-min x-max y-min y-max z-min z-max perspective ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
M: cartesian draw-gadget* ( cartesian -- )
GL_PROJECTION glMatrixMode
glLoadIdentity
M: cartesian establish-coordinate-system ( cartesian -- cartesian )
dup
{
[ x-min>> ] [ x-max>> ]
[ y-min>> ] [ y-max>> ]
[ z-min>> ] [ z-max>> ]
}
cleave
glOrtho
GL_MODELVIEW glMatrixMode
glLoadIdentity
call-next-method ;
{
[ x-min>> ] [ x-max>> ]
[ y-min>> ] [ y-max>> ]
[ z-min>> ] [ z-max>> ]
}
cleave
glOrtho ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

View File

@ -47,12 +47,14 @@ M: function plot-function ( plot function -- plot )
[ [ drop 0 ] [ y-min>> ] bi 2array ]
[ [ drop 0 ] [ y-max>> ] bi 2array ] bi line* ;
M: plot draw-gadget* ( plot -- )
dup call-next-method
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
USING: ui.gadgets.slate ;
M: plot draw-slate ( plot -- plot )
2 glLineWidth
draw-axis
plot-functions
drop
fill-mode
1 glLineWidth ;

View File

@ -21,8 +21,93 @@ TUPLE: slate < gadget action pdim graft ungraft ;
M: slate pref-dim* ( slate -- dim ) pdim>> ;
M: slate draw-gadget* ( slate -- ) origin get swap action>> with-translation ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
USING: combinators arrays sequences math math.geometry
opengl.gl ui.gadgets.worlds ;
: screen-y* ( gadget -- loc )
{
[ find-world height ]
[ screen-loc second ]
[ height ]
}
cleave
+ - ;
: screen-loc* ( gadget -- loc )
{
[ screen-loc first ]
[ screen-y* ]
}
cleave
2array ;
: setup-viewport ( gadget -- gadget )
dup
{
[ screen-loc* ]
[ dim>> ]
}
cleave
gl-viewport ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: default-coordinate-system ( gadget -- gadget )
dup
{
[ drop 0 ]
[ width 1 - ]
[ height 1 - ]
[ drop 0 ]
}
cleave
-1 1
glOrtho ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
M: slate graft* ( slate -- ) graft>> call ;
M: slate ungraft* ( slate -- ) ungraft>> call ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
GENERIC: establish-coordinate-system ( gadget -- gadget )
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
M: slate establish-coordinate-system ( slate -- slate )
default-coordinate-system ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
GENERIC: draw-slate ( slate -- slate )
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
M: slate draw-slate ( slate -- slate ) dup action>> call ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
M: slate draw-gadget* ( slate -- )
GL_PROJECTION glMatrixMode glPushMatrix glLoadIdentity
establish-coordinate-system
GL_MODELVIEW glMatrixMode glLoadIdentity glPushMatrix
setup-viewport
draw-slate
GL_PROJECTION glMatrixMode glPopMatrix
GL_MODELVIEW glMatrixMode glPopMatrix
dup
find-world
default-coordinate-system
setup-viewport
drop
drop ;