17 |
|
|
18 |
ptextures = {} |
ptextures = {} |
19 |
|
|
20 |
# XXX: where should this code be? -------------- |
from gfx.libpaper.texcache import getCachedTexture |
|
from gzz.gfx.gl import GL |
|
|
from gfx.libutil.myimport import get_file_ctime |
|
|
import os |
|
|
if "texcache" not in globals().keys(): |
|
|
texcache = {} |
|
|
|
|
|
def getCachedTexture(args): |
|
|
global texcache |
|
|
|
|
|
name = args[6] |
|
|
file = "gfx/libtexture/" + name |
|
|
binfile = file + ".bin" |
|
|
srcfile = file + ".texture" |
|
|
|
|
|
bintime = get_file_ctime(binfile) |
|
|
srctime = get_file_ctime(srcfile) |
|
|
|
|
|
if srctime > bintime: |
|
|
os.system("make -C gfx/libtexture " + name + ".bin") |
|
|
bintime = get_file_ctime(binfile) |
|
|
|
|
|
key = str(args) |
|
|
if texcache.has_key(key) and texcache[(key,"ctime")] == srctime: |
|
|
#print "Returning cached texture" |
|
|
return texcache[key] |
|
|
|
|
|
tex = GL.createTexture() |
|
|
res = tex.shade(*args) |
|
|
texcache[key] = tex |
|
|
texcache[(key,"ctime")] = srctime |
|
|
print "SHADER: ", res, tex.getTexId() |
|
|
return tex |
|
|
# ---------------------------------------------- |
|
|
|
|
21 |
|
|
22 |
class NamedTexture: |
class NamedTexture: |
23 |
def __init__(self, dict): |
def __init__(self, dict): |