2017-10-09 13:01:41 -04:00
|
|
|
USING: accessors alien.c-types alien.data assocs classes
|
|
|
|
combinators destructors fry kernel math sequences
|
|
|
|
specialized-arrays ui.backend words ;
|
2009-09-09 23:33:34 -04:00
|
|
|
SPECIALIZED-ARRAY: int
|
2009-04-30 21:31:33 -04:00
|
|
|
IN: ui.pixel-formats
|
|
|
|
|
2009-05-01 10:09:38 -04:00
|
|
|
SYMBOLS:
|
2009-04-30 21:31:33 -04:00
|
|
|
double-buffered
|
|
|
|
stereo
|
|
|
|
offscreen
|
|
|
|
fullscreen
|
|
|
|
windowed
|
|
|
|
accelerated
|
|
|
|
software-rendered
|
|
|
|
backing-store
|
|
|
|
multisampled
|
2017-01-29 23:07:28 -05:00
|
|
|
supersampled
|
2009-04-30 21:31:33 -04:00
|
|
|
sample-alpha
|
|
|
|
color-float ;
|
|
|
|
|
|
|
|
TUPLE: pixel-format-attribute { value integer } ;
|
|
|
|
|
|
|
|
TUPLE: color-bits < pixel-format-attribute ;
|
|
|
|
TUPLE: red-bits < pixel-format-attribute ;
|
|
|
|
TUPLE: green-bits < pixel-format-attribute ;
|
|
|
|
TUPLE: blue-bits < pixel-format-attribute ;
|
|
|
|
TUPLE: alpha-bits < pixel-format-attribute ;
|
|
|
|
|
|
|
|
TUPLE: accum-bits < pixel-format-attribute ;
|
|
|
|
TUPLE: accum-red-bits < pixel-format-attribute ;
|
|
|
|
TUPLE: accum-green-bits < pixel-format-attribute ;
|
|
|
|
TUPLE: accum-blue-bits < pixel-format-attribute ;
|
|
|
|
TUPLE: accum-alpha-bits < pixel-format-attribute ;
|
|
|
|
|
|
|
|
TUPLE: depth-bits < pixel-format-attribute ;
|
|
|
|
|
|
|
|
TUPLE: stencil-bits < pixel-format-attribute ;
|
|
|
|
|
|
|
|
TUPLE: aux-buffers < pixel-format-attribute ;
|
|
|
|
|
|
|
|
TUPLE: sample-buffers < pixel-format-attribute ;
|
|
|
|
TUPLE: samples < pixel-format-attribute ;
|
|
|
|
|
2017-01-30 00:17:37 -05:00
|
|
|
HOOK: (make-pixel-format) ui-backend ( world attributes --
|
|
|
|
pixel-format-handle )
|
2009-05-02 13:31:33 -04:00
|
|
|
HOOK: (free-pixel-format) ui-backend ( pixel-format -- )
|
2009-04-30 21:31:33 -04:00
|
|
|
|
2009-05-02 13:31:33 -04:00
|
|
|
ERROR: invalid-pixel-format-attributes world attributes ;
|
2009-05-01 13:56:52 -04:00
|
|
|
|
2009-08-24 21:33:27 -04:00
|
|
|
TUPLE: pixel-format < disposable world handle ;
|
2009-04-30 21:31:33 -04:00
|
|
|
|
2009-05-02 13:31:33 -04:00
|
|
|
: <pixel-format> ( world attributes -- pixel-format )
|
|
|
|
2dup (make-pixel-format)
|
2009-08-24 21:45:19 -04:00
|
|
|
[ pixel-format new-disposable swap >>handle swap >>world ]
|
2015-08-13 19:13:05 -04:00
|
|
|
[ invalid-pixel-format-attributes ]
|
2009-08-24 21:33:27 -04:00
|
|
|
?if ;
|
2009-04-30 21:31:33 -04:00
|
|
|
|
2009-08-24 21:33:27 -04:00
|
|
|
M: pixel-format dispose*
|
2009-05-02 13:31:33 -04:00
|
|
|
[ (free-pixel-format) ] [ f >>handle drop ] bi ;
|
2009-04-30 21:31:33 -04:00
|
|
|
|
2017-10-09 13:01:41 -04:00
|
|
|
: (pixel-format-attribute) ( attribute table -- arr/f )
|
|
|
|
[ dup class-of ] dip at [ swap value>> suffix ] [ drop f ] if* ;
|
|
|
|
|
|
|
|
: pixel-format-attribute>array ( obj table -- arr/f )
|
|
|
|
{
|
|
|
|
{ [ over pixel-format-attribute? ] [ (pixel-format-attribute) ] }
|
|
|
|
{ [ over word? ] [ at ] }
|
|
|
|
[ 2drop f ]
|
|
|
|
} cond ;
|
|
|
|
|
2017-01-29 23:43:19 -05:00
|
|
|
: pixel-format-attributes>int-array ( attrs perm table -- arr )
|
2017-10-09 13:01:41 -04:00
|
|
|
swapd '[ _ pixel-format-attribute>array ] map sift concat append
|
2017-01-29 23:43:19 -05:00
|
|
|
! 0 happens to work as a sentinel value for all ui backends.
|
|
|
|
0 suffix int >c-array ;
|
|
|
|
|
2009-05-02 22:54:25 -04:00
|
|
|
GENERIC: world-pixel-format-attributes ( world -- attributes )
|
|
|
|
|
2017-06-01 14:58:58 -04:00
|
|
|
GENERIC#: check-world-pixel-format 1 ( world pixel-format -- )
|