1 |
# A simple window for testing shaders and adjusting parameters |
# A simple window for testing shaders and adjusting parameters |
2 |
|
# |
3 |
|
# Use +/- to change between the libtexture textures listed in args below |
4 |
|
# or set the global variable tex to some other GL.Texture |
5 |
|
|
6 |
from __future__ import nested_scopes |
from __future__ import nested_scopes |
7 |
|
|
8 |
import math |
import math |
9 |
|
|
10 |
#tex = GL.createTexture() |
#tex = GL.createTexture() |
11 |
|
|
12 |
|
tres = 128 |
13 |
#tex.shade(256, 256, 0, 3, "RGB", "RGB", "fnoise", |
args = [ |
14 |
# ["scale", ".43", "freq", "1", "df", "2", "bias", "0.5", "seed", "1412"]) |
[tres, tres, 0, 4, "RGBA", "RGBA", "fnoise", |
15 |
#tex.shade(256, 256, 0, 3, "RGB", "RGB", "fnoise", |
["scale", "2.5", "freq", "1", "df", "2", "bias", "0.5"]], |
16 |
# ["scale", "2.5", "freq", "1", "df", "2", "bias", "0.5"]) |
[tres, tres, 0, 4, "RGBA", "RGBA", "fnoise", |
17 |
|
["scale", ".43", "freq", "1", "df", "2", "bias", "0.5", |
18 |
#tex.shade(256, 256, 0, 4, "RGBA", "RGBA", "geometric", ["type", "4"]) |
"seed", "1412"]], |
19 |
|
[tres, tres, 0, 4, "RGBA", "RGBA", "fnoise", |
20 |
|
["turb", "1", "scale", ".3", "freq", "1", |
21 |
#tex.shade(256, 256, 0, 3, "RGB", "RGB", "fnoise", |
"freq2", "100", "df", "2", "bias", "0"]], |
22 |
# ["turb", "1", "scale", ".3", "freq", "1", "freq2", "100", "df", "2", "bias", "0"]) |
[64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "0"]], |
23 |
|
[64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "1"]], |
24 |
|
[64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "2"]], |
25 |
|
[64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "3"]], |
26 |
|
[64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "4"]], |
27 |
|
[64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "5"]], |
28 |
|
] |
29 |
|
|
30 |
from gfx.libpaper.textures import getCachedTexture |
from gfx.libpaper.textures import getCachedTexture |
31 |
|
|
|
tex = getCachedTexture([256, 256, 0, 4, "RGBA", "RGBA", "geometric", ["type", "5"]]) |
|
|
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
class TexLabScene: |
class TexLabScene: |
36 |
def __init__(self): |
def __init__(self): |
37 |
pass |
self.ind = 0 |
38 |
|
if not globals().has_key("tex"): self.inittex() |
39 |
|
|
40 |
|
def inittex(self): |
41 |
|
global tex |
42 |
|
tex = getCachedTexture(args[self.ind]) |
43 |
|
|
44 |
def key(self, k): |
def key(self, k): |
45 |
|
reinit = 0 |
46 |
|
if k == "+": self.ind = (self.ind+1) % len(args); reinit=1 |
47 |
|
if k == "-": self.ind = (self.ind+len(args)-1) % len(args); reinit=1 |
48 |
|
|
49 |
|
if reinit: |
50 |
|
self.inittex() |
51 |
|
print "Texture", self.ind |
52 |
|
|
53 |
pass |
pass |
54 |
|
|
55 |
def scene(self, vs): |
def scene(self, vs): |
56 |
|
|
57 |
putnoc(vs, background((0.5,0.5,0.5))) |
putnoc(vs, background((0.5,0.5,0.5))) |
62 |
|
|
63 |
vs.map.put(getDList(""" |
vs.map.put(getDList(""" |
64 |
BindTexture TEXTURE_2D %s |
BindTexture TEXTURE_2D %s |
65 |
TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR |
TexParameter TEXTURE_2D TEXTURE_MAG_FILTER NEAREST |
66 |
TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR |
TexParameter TEXTURE_2D TEXTURE_MIN_FILTER NEAREST |
67 |
Enable TEXTURE_2D |
Enable TEXTURE_2D |
68 |
Disable ALPHA_TEST |
Disable ALPHA_TEST |
69 |
Color 1 1 1 |
Color 1 1 1 |
77 |
TexCoord 1 1 |
TexCoord 1 1 |
78 |
Vertex 1 1 |
Vertex 1 1 |
79 |
End |
End |
80 |
Translate 1 0 0 |
Translate 1.1 0 0 |
81 |
Color 1 0 0 |
Color 1 0 0 |
82 |
Begin QUAD_STRIP |
Begin QUAD_STRIP |
83 |
TexCoord 0 0 |
TexCoord 0 0 |
89 |
TexCoord 1 1 |
TexCoord 1 1 |
90 |
Vertex 1 1 |
Vertex 1 1 |
91 |
End |
End |
92 |
Translate 1 0 0 |
Translate 1.1 0 0 |
93 |
Color 0 1 0 |
Color 0 1 0 |
94 |
Begin QUAD_STRIP |
Begin QUAD_STRIP |
95 |
TexCoord 0 0 |
TexCoord 0 0 |
101 |
TexCoord 1 1 |
TexCoord 1 1 |
102 |
Vertex 1 1 |
Vertex 1 1 |
103 |
End |
End |
104 |
Translate 1 0 0 |
Translate 1.1 0 0 |
105 |
Color 0 0 1 |
Color 0 0 1 |
106 |
Begin QUAD_STRIP |
Begin QUAD_STRIP |
107 |
TexCoord 0 0 |
TexCoord 0 0 |
113 |
TexCoord 1 1 |
TexCoord 1 1 |
114 |
Vertex 1 1 |
Vertex 1 1 |
115 |
End |
End |
116 |
Translate 1 0 0 |
Translate 1.1 0 0 |
117 |
Color 0 0 0 |
Color 0 0 0 |
118 |
BlendFunc ZERO SRC_ALPHA |
BlendFunc ZERO SRC_ALPHA |
119 |
Enable BLEND |
Enable BLEND |