Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


This leave a bad taste in your mouth?

This topic is 5602 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

I am currently writing a general DirectX/Win32 wrapper. There is a large amount of data that is used by all of the DirectX API''s (input, 3d, etc) as well as by the Win32 API. I decided to make matters much cleaner to deal with by simply creating a class to solely store data that is routinely accessed. So far so good, but now I take a turn from the common I think. I decided to create a public global instance of this class for use by all the various wrapper classes. Everything works absolutely perfectly this way. An obvious example would be toggling full screen/windowed mode. With a few changes to the global DataHolder and another call to Create() in the window class, everything is setup... I am just wondering if it would have been considered better technique to have forced each wrapper to be passed a pointer to a DataHolder object at construction.. I avoided this since I felt it might lead to complications. For example: I would obviously declare and define a DataHolder object in my EntryPoint ( Right now its main() ). And I would then instantiate all the wrapper''s off of this DataHolder object, but then comes the problem of other functions in the scope of my entry point. For example, I might have a render function... which is going to be dependant upon a 3d wrapper at minimum, so I end up passing it the pointer every frame, or I declare the 3d wrapper global as well.. Now suppose the Render function wants to modify the data the wrapper is dependant upon (ie- change it to windowed mode again), then it will likely be forced to get a pointer to the dataholder object from the 3d wrapper, etc, etc... It just seemed to save lots of potential trouble by simply making the data object global. Only downside is it seems to go against pretty much of everything I''ve ever learned "style" wise. I''m curious what other people would prefer to see/implement themselves, particularly from others who have worked on teams a fair amount.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!