Copies of Textures of 3d meshes in .x files
Well in my game I have loaded more than 30 meshes and made one or more mesh objects. The meshes are of .x(dot ex format!hehe) and the texture names are embeded in them.But all the meshes are having same bitmap texture
My question is that if I am loading all the meshes seperately will dx load the same texture 30 times or keep only one copy of the texture?
You can do like I did, and have a ResourceManager class that handles that.
mine currently handles the model loading only, I have to modify my model loading class to do the same with the textures...
anyway, what I did was something like
CModel* MyModel = ResourceManager::GetInstance->GetModel("MyModel.x")
what GetModel does is find the "MyModel.x" in a map container, if it doesn't find it, it loads the .X file and stores the model pointers in the map. So it doesn't get loaded twice.
When you're loading the textures, you could do the same. first search in a Map that contains all textures already loaded, if it ain't found, load and add.
You can also add a RefNum to your model/texture objects, so that you can know how many mesh/textures are currently in "use" so you don't delete one that is still in use.
mine currently handles the model loading only, I have to modify my model loading class to do the same with the textures...
anyway, what I did was something like
CModel* MyModel = ResourceManager::GetInstance->GetModel("MyModel.x")
what GetModel does is find the "MyModel.x" in a map container, if it doesn't find it, it loads the .X file and stores the model pointers in the map. So it doesn't get loaded twice.
When you're loading the textures, you could do the same. first search in a Map that contains all textures already loaded, if it ain't found, load and add.
You can also add a RefNum to your model/texture objects, so that you can know how many mesh/textures are currently in "use" so you don't delete one that is still in use.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement