Simplify do-matrix

db4
Slava Pestov 2009-04-04 20:03:30 -05:00
parent b4a74f55a3
commit e84cc5f82d
3 changed files with 7 additions and 7 deletions

View File

@ -15,8 +15,8 @@ HELP: do-enabled
{ $description "Wraps a quotation in " { $link glEnable } "/" { $link glDisable } " calls." } ;
HELP: do-matrix
{ $values { "mode" { $link GL_MODELVIEW } " or " { $link GL_PROJECTION } } { "quot" quotation } }
{ $description "Saves and restores the matrix specified by " { $snippet "mode" } " before and after calling the quotation." } ;
{ $values { "quot" quotation } }
{ $description "Saves and restores the current matrix before and after calling the quotation." } ;
HELP: gl-line
{ $values { "a" "a pair of integers" } { "b" "a pair of integers" } }

View File

@ -44,9 +44,8 @@ MACRO: all-enabled ( seq quot -- )
MACRO: all-enabled-client-state ( seq quot -- )
[ words>values ] dip '[ _ _ (all-enabled-client-state) ] ;
: do-matrix ( mode quot -- )
swap [ glMatrixMode glPushMatrix call ] keep
glMatrixMode glPopMatrix ; inline
: do-matrix ( quot -- )
glPushMatrix call glPopMatrix ; inline
: gl-material ( face pname params -- )
float-array{ } like glMaterialfv ;
@ -165,7 +164,7 @@ MACRO: set-draw-buffers ( buffers -- )
: delete-dlist ( id -- ) 1 glDeleteLists ;
: with-translation ( loc quot -- )
GL_MODELVIEW [ [ gl-translate ] dip call ] do-matrix ; inline
[ [ gl-translate ] dip call ] do-matrix ; inline
: fix-coordinates ( point1 point2 -- x1 y2 x2 y2 )
[ first2 [ >fixnum ] bi@ ] bi@ ;
@ -177,6 +176,7 @@ MACRO: set-draw-buffers ( buffers -- )
fix-coordinates glViewport ;
: init-matrices ( -- )
#! Leaves with matrix mode GL_MODELVIEW
GL_PROJECTION glMatrixMode
glLoadIdentity
GL_MODELVIEW glMatrixMode

View File

@ -66,7 +66,7 @@ M: string draw-text draw-string ;
M: selection draw-text draw-string ;
M: array draw-text
GL_MODELVIEW [
[
[
[ draw-string ]
[ [ 0.0 ] 2dip string-height 0.0 glTranslated ] 2bi