]> gitweb.factorcode.org Git - factor.git/commitdiff
OS-independent pixel formats abstraction
authorJoe Groff <arcata@gmail.com>
Fri, 1 May 2009 01:31:33 +0000 (20:31 -0500)
committerJoe Groff <arcata@gmail.com>
Fri, 1 May 2009 01:31:33 +0000 (20:31 -0500)
basis/ui/pixel-formats/pixel-formats.factor [new file with mode: 0644]

diff --git a/basis/ui/pixel-formats/pixel-formats.factor b/basis/ui/pixel-formats/pixel-formats.factor
new file mode 100644 (file)
index 0000000..09450f2
--- /dev/null
@@ -0,0 +1,58 @@
+USING: destructors math ui.backend ;
+IN: ui.pixel-formats
+
+SINGLETONS:
+    double-buffered
+    stereo
+    offscreen
+    fullscreen
+    windowed
+    accelerated
+    software-rendered
+    robust
+    backing-store
+    multisampled
+    supersampled 
+    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: buffer-level < pixel-format-attribute ;
+
+TUPLE: sample-buffers < pixel-format-attribute ;
+TUPLE: samples < pixel-format-attribute ;
+
+HOOK: (make-pixel-format) ui-backend ( attributes -- pixel-format-handle )
+HOOK: (free-pixel-format) ui-backend ( pixel-format-handle -- )
+HOOK: (pixel-format-attribute) ui-backend ( pixel-format-handle attribute-name -- value )
+
+TUPLE: pixel-format { handle read-only } ;
+
+: <pixel-format> ( attributes -- pixel-format )
+    (make-pixel-format) pixel-format boa ;
+
+M: pixel-format dispose
+    [ [ (free-pixel-format) ] when* f ] change-handle drop ;
+
+: pixel-format-attribute ( pixel-format attribute-name -- value )
+    [ handle>> ] dip (pixel-format-attribute) ;
+