1 USING: accessors alien.c-types alien.data assocs classes
2 combinators destructors kernel math sequences specialized-arrays
21 TUPLE: pixel-format-attribute { value integer } ;
23 TUPLE: color-bits < pixel-format-attribute ;
24 TUPLE: red-bits < pixel-format-attribute ;
25 TUPLE: green-bits < pixel-format-attribute ;
26 TUPLE: blue-bits < pixel-format-attribute ;
27 TUPLE: alpha-bits < pixel-format-attribute ;
29 TUPLE: accum-bits < pixel-format-attribute ;
30 TUPLE: accum-red-bits < pixel-format-attribute ;
31 TUPLE: accum-green-bits < pixel-format-attribute ;
32 TUPLE: accum-blue-bits < pixel-format-attribute ;
33 TUPLE: accum-alpha-bits < pixel-format-attribute ;
35 TUPLE: depth-bits < pixel-format-attribute ;
37 TUPLE: stencil-bits < pixel-format-attribute ;
39 TUPLE: aux-buffers < pixel-format-attribute ;
41 TUPLE: sample-buffers < pixel-format-attribute ;
42 TUPLE: samples < pixel-format-attribute ;
44 HOOK: (make-pixel-format) ui-backend ( world attributes --
46 HOOK: (free-pixel-format) ui-backend ( pixel-format -- )
48 ERROR: invalid-pixel-format-attributes world attributes ;
50 TUPLE: pixel-format < disposable world handle ;
52 : <pixel-format> ( world attributes -- pixel-format )
53 2dup (make-pixel-format)
54 [ pixel-format new-disposable swap >>handle swap >>world ]
55 [ invalid-pixel-format-attributes ]
58 M: pixel-format dispose*
59 [ (free-pixel-format) ] [ f >>handle drop ] bi ;
61 : (pixel-format-attribute) ( attribute table -- arr/f )
62 [ dup class-of ] dip at [ swap value>> suffix ] [ drop f ] if* ;
64 : pixel-format-attribute>array ( obj table -- arr/f )
66 { [ over pixel-format-attribute? ] [ (pixel-format-attribute) ] }
67 { [ over word? ] [ at ] }
71 : pixel-format-attributes>int-array ( attrs perm table -- arr )
72 swapd '[ _ pixel-format-attribute>array ] map sift concat append
73 ! 0 happens to work as a sentinel value for all ui backends.
74 0 suffix int >c-array ;
76 GENERIC: world-pixel-format-attributes ( world -- attributes )
78 GENERIC#: check-world-pixel-format 1 ( world pixel-format -- )