13 |
if not globals().has_key("texcache"): |
if not globals().has_key("texcache"): |
14 |
texcache = {} |
texcache = {} |
15 |
|
|
16 |
def getCachedTexture(args): |
def getCachedTexture(args, shade_all_levels = 0): |
17 |
global texcache |
global texcache |
18 |
|
|
19 |
name = args[6] |
name = args[6] |
27 |
if srctime > bintime: |
if srctime > bintime: |
28 |
os.system("make -C gfx/libtexture " + name + ".bin") |
os.system("make -C gfx/libtexture " + name + ".bin") |
29 |
|
|
30 |
key = str(args) |
key = str((args,shade_all_levels)) |
31 |
if texcache.has_key(key) and texcache[(key,"ctime")] == srctime: |
if texcache.has_key(key) and texcache[(key,"ctime")] == srctime: |
32 |
#print "Returning cached texture" |
#print "Returning cached texture" |
33 |
return texcache[key] |
return texcache[key] |
34 |
|
|
35 |
tex = GL.createTexture() |
tex = GL.createTexture() |
36 |
res = tex.shade(*args) |
if shade_all_levels: |
37 |
|
res = tex.shade_all_levels(*args) |
38 |
|
else: |
39 |
|
res = tex.shade(*args) |
40 |
|
|
41 |
texcache[key] = tex |
texcache[key] = tex |
42 |
texcache[(key,"ctime")] = srctime |
texcache[(key,"ctime")] = srctime |
43 |
print "SHADER: ", res, tex.getTexId() |
print "SHADER: ", res, tex.getTexId() |