Hello
I am currently working on translating some Panda3D examples from Python to C++ and faced a technical issue that I need some help with.
I am trying to load a model and apply a texture to it ; but my C++ code doesn’t working as expected. The model loads fine, but the texture does not appear.
Below are relevant part of my code:
#include “pandaFramework.h”
#include “pandaSystem.h”
PandaFramework framework;
int main(int argc, char *argv) {
framework.open_framework(argc, argv);
framework.set_window_title(“My Panda3D Window”);
WindowFramework *window = framework.open_window();
if (window != nullptr) {
NodePath model = window->load_model(framework.get_models(), "models/panda");
model.reparent_to(window->get_render());
// Attempt to apply texture
PT(Texture) texture = TexturePool::load_texture("models/maps/panda_texture.png");
if (texture != nullptr) {
model.set_texture(texture);
} else {
std::cerr << "Failed to load texture" << std::endl;
}
window->get_camera_group().set_pos(0, -10, 0);
}
framework.main_loop();
framework.close_framework();
return 0;
}
The model appears correctly, but without the texture. The console outputs “Failed to load texture”, indicating that the texture loading part is failing. I have verified that the path to the texture is correct.
I have referred Panda3D C++ API documentation and the TexturePool-class-salesforce cpq documentation but haven’t been able to resolve the issue.
Could anyone suggest any debugging steps?
Thank you in advance!
Best regards,
nathaniel