[SOLVED] Problem loading resources


I’ve got a problem loading resources like shaders and textures but not models

my folder structure looks like this


my prc looks like this

model-path    $MAIN_DIR
model-path    $THIS_PRC_DIR/..

If I try load the shaders or the textures from my folder I get null pointers back.

mTerrainVS->load("Terrain/Shaders/Terrain.vs", Shader::SL_GLSL);

PT(Texture) dirt = new Texture();

the shader is 0x00000000 and the texture is a valid pointer but the content looks like it’s not loaded anything.

I have tried various things and even simplified the path (i.e. put the shader and the texture into the “MyData” folder directly) but all failed.

ConfigPage* pConfig = load_prc_file("../MyData/MyConfig/Config.prc");

returns a valid pointer and in fact I can load models from my data folder.

any ideas what’s going wrong here ?


You are using the wrong interface. Texture::read() and Shader::load() are low-level calls that do not search the model path. Instead, use TexturePool::load_texture() and ShaderPool::load_shader(). These higher-level objects also will automatically cache file references, so multiple loads to the same filename will return the same object.


okay thanks for the answer

the texture loading works now

PT(Texture) dirt = TexturePool::load_texture("Terrain/Textures/dirt.dds");

but the shader is still null

CPT(Shader) mTerrainVS = ShaderPool::load_shader("Terrain/Shaders/Terrain.vs");

oh… it’s case sensitive. I tried

CPT(Shader) mTerrainVS = ShaderPool::load_shader("Terrain/Shaders/terrain.vs");

(small “t” in “terrain” )

and the shader loads now.

I wasn’t aware that panda was using case sensitive paths ?

Yes. Panda is case-sensitive, because some operating systems are case-sensitive (and p3d files are case-sensitive), so it’s necessary to write case-sensitive filenames in order to ensure your code remains portable.

For the record, if you have no intention of ever running your code on anything other than Windows, and no intention of ever packaging it in a p3d file, and you like being sloppy with filename case, you can put:

vfs-case-sensitive 0

in your Config.prc file to turn off the case sensitivity.


Thanks for the info - I think I’ll simple enforce the case sensitivity.