interfacing with panda3d texture cache

I want to be able to create textures during run time but i also don’t want to recreate them over and over again. Is there a way to write them to panda3d cache via txo files and only recreate them if they are needed.

Basically i need “if exture exists” and “store texture” in cache. Also is mipmapping and compression intermediates stuff cached?

I basically want to understand how it all works so that i can use this to my advantage.

bamCache = BamCache.getGlobalPtr()
r = bamCache.lookup('/my/virtual/filename', 'txo')
if r.hasData():
    print "Cache file already exists"
    tex = r.getData()
else:
    print "Cache file does not exist"
    tex = createTexture()
    r.setData(tex, False)
    bamCache.store(r)

All properties of textures, including mipmapping, compression data, and whatnot, are stored.

David

Thanks alot thats quite simple!