problem of reloading a material

Problems building or running the engine, queries about how to use features etc.
Post Reply
Kinian
Gnoblar
Posts: 5
Joined: Wed Apr 18, 2012 1:27 pm

problem of reloading a material

Post by Kinian »

I use OGRE 1.9 on Linux (x86_64) and embedded Linux (OpenGL ES 2.x on Odroid XU-4 ARM 7)

The following code (code 1 and code 2) is working on Linux (CentOS 7.2, with OpenGL)

Code: Select all

//code 1
Entity *ent = mSceneMgr->createEntity("entityname", "meshname.mesh");
SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("nodename");
node->attachObject(ent);
MaterialPtr basemat = Ogre::MaterialManager::getSingletonPtr()->getByName("matname");
MaterialPtr mat = basemat->clone("matnamecopy");
ent->setMaterial(mat);
if SceneNode "nodename" is not needed, I unload the SceneNode, Entity, and Material:

Code: Select all

//code 2
SceneNode *node = mSceneMgr->getSceneNode("nodename");
node->detachAllObjects();
mSceneMgr->destroySceneNode("nodename");
mSceneMgr->destroyEntity("entityname");
MaterialPtr mat = static_cast<MaterialPtr>(MaterialManager::getSingleton().getByName("matnamecopy"));
mat->unload();
ResourcePtr pRes = static_cast<ResourcePtr>(mat);
MaterialManager::getSingleton().remove(pRes);
when I use code 1 to create entity, scenenode, and clone material again, it is working on CentOS.

But it is not working on Odroid (Ubuntu 15.04, OpenGL ES 2.x)
mesh displays correctly on the first time after I create entity, scenenode, and clone material.
When I unload SceneNode, Entity, and Material (using code 2),
and create entity, scenenode, and clone material (using code 1) again, mesh does not display.

If think there is something wrong with material.
Because if I use another material name, it is working on Odroid.
(e.g., "matnamecopy" for the 1st clone of material, and "matnamecopy2" for the 2nd clone of material,
"entityname" and "nodename" do not change for the 1st and 2nd time of creation)
Post Reply