]> gitweb.factorcode.org Git - factor.git/blob - extra/gpu/util/util.factor
merge project-euler.factor
[factor.git] / extra / gpu / util / util.factor
1 ! (c)2009 Joe Groff bsd license
2 USING: gpu.buffers gpu.render gpu.shaders gpu.textures images kernel
3 specialized-arrays ;
4 FROM: alien.c-types => float ;
5 SPECIALIZED-ARRAY: float
6 IN: gpu.util
7
8 CONSTANT: environment-cube-map-mv-matrices
9     H{
10         { +X {
11             {  0.0  0.0 -1.0  0.0 }
12             {  0.0 -1.0  0.0  0.0 }
13             { -1.0  0.0  0.0  0.0 }
14             {  0.0  0.0  0.0  1.0 }
15         } }
16         { +Y {
17             {  1.0  0.0  0.0  0.0 }
18             {  0.0  0.0  1.0  0.0 }
19             {  0.0 -1.0  0.0  0.0 }
20             {  0.0  0.0  0.0  1.0 }
21         } }
22         { +Z {
23             {  1.0  0.0  0.0  0.0 }
24             {  0.0 -1.0  0.0  0.0 }
25             {  0.0  0.0 -1.0  0.0 }
26             {  0.0  0.0  0.0  1.0 }
27         } }
28         { -X {
29             {  0.0  0.0  1.0  0.0 }
30             {  0.0 -1.0  0.0  0.0 }
31             {  1.0  0.0  0.0  0.0 }
32             {  0.0  0.0  0.0  1.0 }
33         } }
34         { -Y {
35             {  1.0  0.0  0.0  0.0 }
36             {  0.0  0.0 -1.0  0.0 }
37             {  0.0  1.0  0.0  0.0 }
38             {  0.0  0.0  0.0  1.0 }
39         } }
40         { -Z {
41             { -1.0  0.0  0.0  0.0 }
42             {  0.0 -1.0  0.0  0.0 }
43             {  0.0  0.0  1.0  0.0 }
44             {  0.0  0.0  0.0  1.0 }
45         } }
46     }
47
48 VERTEX-FORMAT: window-vertex
49     { "vertex" float-components 2 f } ;
50
51 CONSTANT: window-vertexes
52     float-array{
53         -1.0 -1.0
54         -1.0  1.0
55          1.0 -1.0
56          1.0  1.0
57     }
58
59 : <window-vertex-buffer> ( -- buffer )
60     window-vertexes 
61     static-upload draw-usage vertex-buffer
62     byte-array>buffer ;
63
64 : <window-vertex-array> ( program-instance -- vertex-array )
65     [ <window-vertex-buffer> ] dip window-vertex buffer>vertex-array ;