Jump to content
  • Advertisement
Sign in to follow this  
eltharynd

variable static member

This topic is 2114 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok I've got a class that i use to instance various objects.... 

I need to declare a static map that stores pointers to directx objects so that when i initialize the specific objects it compiles and creates the objects only if it doesn't exists...

 

I tried with static map<key, pointer> but that way I should initialize the map to be constant....

 

I need an alternative to make it variable YET common to all instances of the class that stores it.. any idea?

Share this post


Link to post
Share on other sites
Advertisement

What's wrong with the static member and what do you mean you have to initialize it to be constant?

Edited by Brother Bob

Share this post


Link to post
Share on other sites

ok I'll try to explain this better..

 

I've got this object that needs to store multiple pointers to shaders and input layouts.... 

so that if the specific shader compiles/creates it stores it in a map so i don't have to recompile/create it later.. 

 

I was thinking to achieve this with a map that stores the pointer to the shader createt and uses the file path of the shader as a key...

so that every time i initialize an instance of the object class i can simply check if the specific filepath has already been inserted in the map or, if not, create it and insert it...

 

hope this explains... :/

Share this post


Link to post
Share on other sites

that's what i was thinking... but i wasn't sure whether there was a simpler solution i did not know about.. i have to recode all of the engine :)

Share this post


Link to post
Share on other sites

I still don't see what makes you think that you can't have a non-constant static member. Can you post a tiny piece of code where you try and fail?

Share this post


Link to post
Share on other sites

How much effort is that? Have you already got a static map in your class? (If you have, how many errors do you get if you comment it out? That should give you an idea of how much work is involved refactoring).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!