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