]> gitweb.factorcode.org Git - factor.git/blob - extra/gpu/util/util.factor
512cea4a17cdf65f24549b999b1ce970dcbcff50
[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.float ;
4 IN: gpu.util
5
6 CONSTANT: environment-cube-map-mv-matrices
7     H{
8         { +X {
9             {  0.0  0.0 -1.0  0.0 }
10             {  0.0 -1.0  0.0  0.0 }
11             { -1.0  0.0  0.0  0.0 }
12             {  0.0  0.0  0.0  1.0 }
13         } }
14         { +Y {
15             {  1.0  0.0  0.0  0.0 }
16             {  0.0  0.0  1.0  0.0 }
17             {  0.0 -1.0  0.0  0.0 }
18             {  0.0  0.0  0.0  1.0 }
19         } }
20         { +Z {
21             {  1.0  0.0  0.0  0.0 }
22             {  0.0 -1.0  0.0  0.0 }
23             {  0.0  0.0 -1.0  0.0 }
24             {  0.0  0.0  0.0  1.0 }
25         } }
26         { -X {
27             {  0.0  0.0  1.0  0.0 }
28             {  0.0 -1.0  0.0  0.0 }
29             {  1.0  0.0  0.0  0.0 }
30             {  0.0  0.0  0.0  1.0 }
31         } }
32         { -Y {
33             {  1.0  0.0  0.0  0.0 }
34             {  0.0  0.0 -1.0  0.0 }
35             {  0.0  1.0  0.0  0.0 }
36             {  0.0  0.0  0.0  1.0 }
37         } }
38         { -Z {
39             { -1.0  0.0  0.0  0.0 }
40             {  0.0 -1.0  0.0  0.0 }
41             {  0.0  0.0  1.0  0.0 }
42             {  0.0  0.0  0.0  1.0 }
43         } }
44     }
45
46 VERTEX-FORMAT: window-vertex
47     { "vertex" float-components 2 f } ;
48
49 CONSTANT: window-vertexes
50     float-array{
51         -1.0 -1.0
52         -1.0  1.0
53          1.0 -1.0
54          1.0  1.0
55     }
56
57 : <window-vertex-buffer> ( -- buffer )
58     window-vertexes 
59     static-upload draw-usage vertex-buffer
60     byte-array>buffer ;
61
62 : <window-vertex-array> ( program-instance -- vertex-array )
63     [ <window-vertex-buffer> ] dip window-vertex buffer>vertex-array ;