Archived

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

haro

This leave a bad taste in your mouth?

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