WarehouseJim
01-12-2010 13:42:32
Background: I'm using Mogre 1.7.1.0 .NET 4 and Direct3D9 render system. I'm also using Miyagi.
Every frame I update a number of textures that work with InstancedGeometry (and I do similarly with some StaticGeometry). To do this, I get a ResourcePtr from the MaterialsManager and then do:
99% of the time this works fine, but every so often (sometimes after hours of running) it crashes saying it can't cast the ResourcePtr as a MaterialPtr. Does anyone know why this might happen? Is it a bug?
I'm trying to catch the exception and if it occurs, I'll remove the material and texture (referenced by name) from the materialsManager:
then re-create again, but it's a slow process to see if this works given the bug is fairly rare, so any advice is appreciated.
To get around this problem previously, I tried keeping references to the TexturePtr and MaterialPtr, but when I resize the screen I found out that you needed to dispose of the pointers or it would crash - I found out that when you resize, the D3D9RenderSystem sets all the texture buffers to null on the card, and somehow keeping the TexturePtr must have been interrupting it. So I got past one bug, but it still crashed occasionally and it's went totally crazy on another computer with all the textures being screwed up. Can anyone advise me what the general policy should be with pointers and how should you deal with them e.g. disposing etc.
thanks,
WarehouseJim
Every frame I update a number of textures that work with InstancedGeometry (and I do similarly with some StaticGeometry). To do this, I get a ResourcePtr from the MaterialsManager and then do:
MaterialPtr myMaterialPtr = myResourcePtr;
99% of the time this works fine, but every so often (sometimes after hours of running) it crashes saying it can't cast the ResourcePtr as a MaterialPtr. Does anyone know why this might happen? Is it a bug?
I'm trying to catch the exception and if it occurs, I'll remove the material and texture (referenced by name) from the materialsManager:
MaterialManager.Singleton.Remove(myMaterialName);
TextureManager.Singleton.Remove(myTextureName);
then re-create again, but it's a slow process to see if this works given the bug is fairly rare, so any advice is appreciated.
To get around this problem previously, I tried keeping references to the TexturePtr and MaterialPtr, but when I resize the screen I found out that you needed to dispose of the pointers or it would crash - I found out that when you resize, the D3D9RenderSystem sets all the texture buffers to null on the card, and somehow keeping the TexturePtr must have been interrupting it. So I got past one bug, but it still crashed occasionally and it's went totally crazy on another computer with all the textures being screwed up. Can anyone advise me what the general policy should be with pointers and how should you deal with them e.g. disposing etc.
thanks,
WarehouseJim