creating a class for rockets, should i use a static for the models mesh?

Started by
1 comment, last by SuperVGA 13 years, 4 months ago
building a game , which has rockets in it , this will be a class , that has life time , vectors and stuff.
but all instances of this class will have the same mesh.

so i was thinking would it be bes to declare it as static, other wise it will load in meshes which it does not have to .

or is there a better way
Advertisement
You are talking about a generic problem ("reuse certain resources") and one specific approach for solving it ("make them static"). In my opinion, there's nothing wrong with the static approach, as long as you can pull it off without getting into order of initialization troubles. However, you should be aware that this problem can be solved in a variety of different ways. For example, you could introduce a resource manager class that makes sure resources are only loaded once. You can find plenty of information (articles, forum discussions...) about resource management on this site.
You don't have to declare your rockets static just to use a single mesh.
There are many ways to avoid this, but one would be your class having a reference of some sort, maybe a number or a real reference or pointer, to a mesh.
Why not create a simple mesh manager class, which you can index your meshes in?

Edit: ^ too slow! -although a resource manager is more general. Probably a better idea to start off with that, you can always inherit to more specific loaders and managers.

This topic is closed to new replies.

Advertisement