]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/gpu/state/state.factor
use radix literals
[factor.git] / extra / gpu / state / state.factor
index db767740384560dced591ffeebb77f7e8ae0cb7c..0f2ce7cb46e18c7c70cb8b1c2a54265e9d98c14c 100755 (executable)
@@ -4,26 +4,23 @@ combinators gpu kernel literals math math.rectangles opengl
 opengl.gl sequences typed variants specialized-arrays ;
 QUALIFIED-WITH: alien.c-types c
 FROM: math => float ;
-SPECIALIZED-ARRAY: int
+SPECIALIZED-ARRAY: c:int
 SPECIALIZED-ARRAY: c:float
 IN: gpu.state
 
-UNION: ?rect rect POSTPONE: f ;
-UNION: ?float float POSTPONE: f ;
-
 TUPLE: viewport-state
     { rect rect read-only } ;
 C: <viewport-state> viewport-state
 
 TUPLE: scissor-state
-    { rect ?rect read-only } ;
+    { rect maybe: rect read-only } ;
 C: <scissor-state> scissor-state
 
 TUPLE: multisample-state
     { multisample? boolean read-only }
     { sample-alpha-to-coverage? boolean read-only }
     { sample-alpha-to-one? boolean read-only }
-    { sample-coverage ?float read-only }
+    { sample-coverage maybe: float read-only }
     { invert-sample-coverage? boolean read-only } ;
 C: <multisample-state> multisample-state
 
@@ -37,22 +34,18 @@ VARIANT: stencil-op
     op-inc-sat op-dec-sat
     op-inc-wrap op-dec-wrap ;
 
-UNION: ?comparison comparison POSTPONE: f ;
-
 TUPLE: stencil-mode
     { value integer initial: 0 read-only }
-    { mask integer initial: HEX: FFFFFFFF read-only }
+    { mask integer initial: 0xFFFFFFFF read-only }
     { comparison comparison initial: cmp-always read-only }
     { stencil-fail-op stencil-op initial: op-keep read-only }
     { depth-fail-op stencil-op initial: op-keep read-only }
     { depth-pass-op stencil-op initial: op-keep read-only } ;
 C: <stencil-mode> stencil-mode
 
-UNION: ?stencil-mode stencil-mode POSTPONE: f ;
-
 TUPLE: stencil-state
-    { front-mode ?stencil-mode initial: f read-only }
-    { back-mode ?stencil-mode initial: f read-only } ;
+    { front-mode maybe: stencil-mode initial: f read-only }
+    { back-mode maybe: stencil-mode initial: f read-only } ;
 C: <stencil-state> stencil-state
 
 TUPLE: depth-range-state
@@ -61,7 +54,7 @@ TUPLE: depth-range-state
 C: <depth-range-state> depth-range-state
 
 TUPLE: depth-state
-    { comparison ?comparison initial: f read-only } ;
+    { comparison maybe: comparison initial: f read-only } ;
 C: <depth-state> depth-state
 
 VARIANT: blend-equation
@@ -86,19 +79,17 @@ TUPLE: blend-mode
     { dest-function blend-function initial: func-one-minus-source-alpha read-only } ;
 C: <blend-mode> blend-mode
 
-UNION: ?blend-mode blend-mode POSTPONE: f ;
-
 TUPLE: blend-state
     { constant-color sequence initial: f read-only }
-    { rgb-mode ?blend-mode read-only }
-    { alpha-mode ?blend-mode read-only } ;
+    { rgb-mode maybe: blend-mode read-only }
+    { alpha-mode maybe: blend-mode read-only } ;
 C: <blend-state> blend-state
 
 TUPLE: mask-state
     { color sequence initial: { t t t t } read-only }
     { depth boolean initial: t read-only }
-    { stencil-front integer initial: HEX: FFFFFFFF read-only }
-    { stencil-back integer initial: HEX: FFFFFFFF read-only } ;
+    { stencil-front integer initial: 0xFFFFFFFF read-only }
+    { stencil-back integer initial: 0xFFFFFFFF read-only } ;
 C: <mask-state> mask-state
 
 VARIANT: triangle-face
@@ -108,11 +99,9 @@ VARIANT: triangle-cull
 VARIANT: triangle-mode
     triangle-points triangle-lines triangle-fill ;
 
-UNION: ?triangle-cull triangle-cull POSTPONE: f ;
-    
 TUPLE: triangle-cull-state
     { front-face triangle-face initial: face-ccw read-only }
-    { cull ?triangle-cull initial: f read-only } ;
+    { cull maybe: triangle-cull initial: f read-only } ;
 C: <triangle-cull-state> triangle-cull-state
 
 TUPLE: triangle-state
@@ -125,7 +114,7 @@ VARIANT: point-sprite-origin
     origin-upper-left origin-lower-left ;
 
 TUPLE: point-state
-    { size ?float initial: 1.0 read-only }
+    { size maybe: float initial: 1.0 read-only }
     { sprite-origin point-sprite-origin initial: origin-upper-left read-only }
     { fade-threshold float initial: 1.0 read-only } ;
 C: <point-state> point-state
@@ -416,18 +405,18 @@ M: mask-state set-gpu-state*
     [ set-gpu-state* ] if ; inline
 
 : get-gl-bool ( enum -- value )
-    0 <uchar> [ glGetBooleanv ] keep *uchar c-bool> ;
+    0 c:uchar <ref> [ glGetBooleanv ] keep c:uchar deref c-bool> ;
 : get-gl-int ( enum -- value )
-    0 <int> [ glGetIntegerv ] keep *int ;
+    0 c:int <ref> [ glGetIntegerv ] keep c:int deref ;
 : get-gl-float ( enum -- value )
-    0 <float> [ glGetFloatv ] keep *float ;
+    0 c:float <ref> [ glGetFloatv ] keep c:float deref ;
 
 : get-gl-bools ( enum count -- value )
     <byte-array> [ glGetBooleanv ] keep [ c-bool> ] { } map-as ;
 : get-gl-ints ( enum count -- value )
-    <int-array> [ glGetIntegerv ] keep ;
+    c:int <c-array> [ glGetIntegerv ] keep ;
 : get-gl-floats ( enum count -- value )
-    <float-array> [ glGetFloatv ] keep ;
+    c:float <c-array> [ glGetFloatv ] keep ;
 
 : get-gl-rect ( enum -- value )
     4 get-gl-ints first4 [ 2array ] 2bi@ <rect> ;