1 USING: accessors assocs classes destructors functors kernel
2 lexer math parser sequences specialized-arrays.int ui.backend
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: buffer-level < pixel-format-attribute ;
43 TUPLE: sample-buffers < pixel-format-attribute ;
44 TUPLE: samples < pixel-format-attribute ;
46 HOOK: (make-pixel-format) ui-backend ( world attributes -- pixel-format-handle )
47 HOOK: (free-pixel-format) ui-backend ( pixel-format -- )
48 HOOK: (pixel-format-attribute) ui-backend ( pixel-format attribute-name -- value )
50 ERROR: invalid-pixel-format-attributes world attributes ;
52 TUPLE: pixel-format world handle ;
54 : <pixel-format> ( world attributes -- pixel-format )
55 2dup (make-pixel-format)
56 [ nip pixel-format boa ] [ invalid-pixel-format-attributes ] if* ;
58 M: pixel-format dispose
59 [ (free-pixel-format) ] [ f >>handle drop ] bi ;
61 : pixel-format-attribute ( pixel-format attribute-name -- value )
62 (pixel-format-attribute) ;
66 FUNCTOR: define-pixel-format-attribute-table ( NAME PERM TABLE -- )
69 >PFA-int-array DEFINES >${NAME}-int-array
73 GENERIC: >PFA ( attribute -- pfas )
78 TABLE at [ { } ] unless* ;
79 M: pixel-format-attribute >PFA
81 [ swap value>> suffix ]
84 : >PFA-int-array ( attribute -- int-array )
85 [ >PFA ] map concat PERM prepend 0 suffix >int-array ;
89 SYNTAX: PIXEL-FORMAT-ATTRIBUTE-TABLE:
90 scan scan-object scan-object define-pixel-format-attribute-table ;