]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/pixel-formats/pixel-formats.factor
factor: Rename GENERIC# to GENERIC#:.
[factor.git] / basis / ui / pixel-formats / pixel-formats.factor
1 USING: accessors alien.c-types alien.data assocs destructors fry
2 kernel math sequences specialized-arrays ui.backend ;
3 SPECIALIZED-ARRAY: int
4 IN: ui.pixel-formats
5
6 SYMBOLS:
7     double-buffered
8     stereo
9     offscreen
10     fullscreen
11     windowed
12     accelerated
13     software-rendered
14     backing-store
15     multisampled
16     supersampled
17     sample-alpha
18     color-float ;
19
20 TUPLE: pixel-format-attribute { value integer } ;
21
22 TUPLE: color-bits < pixel-format-attribute ;
23 TUPLE: red-bits < pixel-format-attribute ;
24 TUPLE: green-bits < pixel-format-attribute ;
25 TUPLE: blue-bits < pixel-format-attribute ;
26 TUPLE: alpha-bits < pixel-format-attribute ;
27
28 TUPLE: accum-bits < pixel-format-attribute ;
29 TUPLE: accum-red-bits < pixel-format-attribute ;
30 TUPLE: accum-green-bits < pixel-format-attribute ;
31 TUPLE: accum-blue-bits < pixel-format-attribute ;
32 TUPLE: accum-alpha-bits < pixel-format-attribute ;
33
34 TUPLE: depth-bits < pixel-format-attribute ;
35
36 TUPLE: stencil-bits < pixel-format-attribute ;
37
38 TUPLE: aux-buffers < pixel-format-attribute ;
39
40 TUPLE: sample-buffers < pixel-format-attribute ;
41 TUPLE: samples < pixel-format-attribute ;
42
43 HOOK: (make-pixel-format) ui-backend ( world attributes --
44                                        pixel-format-handle )
45 HOOK: (free-pixel-format) ui-backend ( pixel-format -- )
46
47 ERROR: invalid-pixel-format-attributes world attributes ;
48
49 TUPLE: pixel-format < disposable world handle ;
50
51 : <pixel-format> ( world attributes -- pixel-format )
52     2dup (make-pixel-format)
53     [ pixel-format new-disposable swap >>handle swap >>world ]
54     [ invalid-pixel-format-attributes ]
55     ?if ;
56
57 M: pixel-format dispose*
58     [ (free-pixel-format) ] [ f >>handle drop ] bi ;
59
60 : pixel-format-attributes>int-array ( attrs perm table -- arr )
61     swapd '[ _ at ] map sift concat append
62     ! 0 happens to work as a sentinel value for all ui backends.
63     0 suffix int >c-array ;
64
65 GENERIC: world-pixel-format-attributes ( world -- attributes )
66
67 GENERIC#: check-world-pixel-format 1 ( world pixel-format -- )