stealth977
26-08-2009 16:51:30
Problem one, Hydrax crashes on setWaterColour(): (Hydrax.cpp)
the Textures are null at some cases, so the fix is:
Problem 2, hydrax crashes in setCompositorEnabled(...), the problem is not related to this function but related to removeCompositor(...)
(MaterialManager.cpp)
Here the problem is CompositorManager::remove doesnt remove the compositor from the viewport's compositor chain, so when the compositor resource is removed, viewport still has a compositor instance in the chain whose pointer points to an invalid resource, which causes a crash with the next setCompositorEnabled(), fix:
Just remove the compositor from chain before destroying it...
ismail,
mRttManager->getTexture(RttManager::RTT_REFLECTION)->
getBuffer()->getRenderTarget()->getViewport(0)->setBackgroundColour(WC);
mRttManager->getTexture(RttManager::RTT_REFRACTION)->
getBuffer()->getRenderTarget()->getViewport(0)->setBackgroundColour(WC);
the Textures are null at some cases, so the fix is:
Ogre::TexturePtr tex = mRttManager->getTexture(RttManager::RTT_REFLECTION);
if(!tex.isNull())
tex->getBuffer()->getRenderTarget()->getViewport(0)->setBackgroundColour(WC);
tex = mRttManager->getTexture(RttManager::RTT_REFRACTION);
if(!tex.isNull())
tex->getBuffer()->getRenderTarget()->getViewport(0)->setBackgroundColour(WC);
Problem 2, hydrax crashes in setCompositorEnabled(...), the problem is not related to this function but related to removeCompositor(...)
(MaterialManager.cpp)
void MaterialManager::removeCompositor()
{
if (Ogre::MaterialManager::getSingleton().resourceExists(_def_Underwater_Compositor_Material_Name))
{
setCompositorEnable(COMP_UNDERWATER, false);
Ogre::CompositorManager::getSingleton().remove(_def_Underwater_Compositor_Name);
Ogre::MaterialManager::getSingleton().remove(_def_Underwater_Compositor_Material_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().unload(_def_Underwater_Compositor_Shader_VP_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().unload(_def_Underwater_Compositor_Shader_FP_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().remove(_def_Underwater_Compositor_Shader_VP_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().remove(_def_Underwater_Compositor_Shader_FP_Name);
}
}
Here the problem is CompositorManager::remove doesnt remove the compositor from the viewport's compositor chain, so when the compositor resource is removed, viewport still has a compositor instance in the chain whose pointer points to an invalid resource, which causes a crash with the next setCompositorEnabled(), fix:
void MaterialManager::removeCompositor()
{
if (Ogre::MaterialManager::getSingleton().resourceExists(_def_Underwater_Compositor_Material_Name))
{
setCompositorEnable(COMP_UNDERWATER, false);
Ogre::CompositorManager::getSingleton().removeCompositor(mHydrax->getViewport(), _def_Underwater_Compositor_Name);
Ogre::CompositorManager::getSingleton().remove(_def_Underwater_Compositor_Name);
Ogre::MaterialManager::getSingleton().remove(_def_Underwater_Compositor_Material_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().unload(_def_Underwater_Compositor_Shader_VP_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().unload(_def_Underwater_Compositor_Shader_FP_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().remove(_def_Underwater_Compositor_Shader_VP_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().remove(_def_Underwater_Compositor_Shader_FP_Name);
}
}
Just remove the compositor from chain before destroying it...
ismail,