2005-01-23 21:00:52 -05:00
|
|
|
! Copyright (C) 2004, 2005 Slava Pestov.
|
2005-02-11 19:09:48 -05:00
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
2004-10-17 19:10:46 -04:00
|
|
|
IN: sdl
|
2005-03-06 20:03:22 -05:00
|
|
|
USING: kernel lists math namespaces ;
|
2004-10-17 19:10:46 -04:00
|
|
|
|
2005-02-03 22:21:51 -05:00
|
|
|
: rgb ( [ r g b ] -- n )
|
|
|
|
3unlist
|
2005-01-23 16:47:28 -05:00
|
|
|
255
|
2004-10-17 19:10:46 -04:00
|
|
|
swap 8 shift bitor
|
|
|
|
swap 16 shift bitor
|
|
|
|
swap 24 shift bitor ;
|
|
|
|
|
2005-01-23 21:00:52 -05:00
|
|
|
: make-color ( r g b -- color )
|
|
|
|
#! Make an SDL_Color struct. This will go away soon in favor
|
|
|
|
#! of pass-by-value support in the FFI.
|
|
|
|
255 24 shift
|
|
|
|
swap 16 shift bitor
|
|
|
|
swap 8 shift bitor
|
|
|
|
swap bitor ;
|
|
|
|
|
2005-02-03 22:21:51 -05:00
|
|
|
: black [ 0 0 0 ] ;
|
2005-03-05 14:45:23 -05:00
|
|
|
: gray [ 128 128 128 ] ;
|
2005-02-03 22:21:51 -05:00
|
|
|
: white [ 255 255 255 ] ;
|
|
|
|
: red [ 255 0 0 ] ;
|
|
|
|
: green [ 0 255 0 ] ;
|
|
|
|
: blue [ 0 0 255 ] ;
|
2004-11-08 22:36:51 -05:00
|
|
|
|
2005-01-23 16:47:28 -05:00
|
|
|
: with-pixels ( quot -- )
|
|
|
|
width get [
|
|
|
|
height get [
|
|
|
|
[ rot dup slip swap surface get swap ] 2keep
|
|
|
|
[ rot pixelColor ] 2keep
|
|
|
|
] repeat
|
|
|
|
] repeat drop ; inline
|
2004-10-17 19:10:46 -04:00
|
|
|
|
|
|
|
: with-surface ( quot -- )
|
|
|
|
#! Execute a quotation, locking the current surface if it
|
|
|
|
#! is required (eg, hardware surface).
|
|
|
|
[
|
2004-11-08 22:36:51 -05:00
|
|
|
surface get dup must-lock-surface? [
|
2004-12-25 18:08:20 -05:00
|
|
|
dup SDL_LockSurface drop slip dup SDL_UnlockSurface
|
2004-10-17 19:10:46 -04:00
|
|
|
] [
|
|
|
|
slip
|
2004-11-08 22:36:51 -05:00
|
|
|
] ifte SDL_Flip drop
|
2004-12-25 18:08:20 -05:00
|
|
|
] with-scope ; inline
|