An aside, the standardization of namespaces in C++ 1998 helps some to avoid global namespace pollution, however the question from the previous post still deserves a good answer.
-PlaneMith
Avoid global variables?
quote:
Original post by Anonymous Poster
How do you pass values to WndProc without the use of globals? Whenever I use globals I put them in a global structure to avoid namespace conflicts.
One way would be to make use of the 32-bit value associated with each window for use by the application. This value is initially zero and can be changed with SetWindowLong() with GWL_USERDATA as the second parameter and can be accessed with GetWindowLong() with GWL_USERDATA as the second parameter.
You could create a structure local to WinMain() and just set that 32-bit value to the address of that structure. Then whenever you need to access that information just use GetWindowLong().
Anyway.. I hope that helps.
- Ian Perez (fett@willcomp.com) - "It is by will alone I set my mind in motion"
Edited by - [bobafet] on May 2, 2001 1:17:02 AM
- Ian Perez (iperez.fett@verizon.net) - "It is by will alone I set my mind in motion"
So avoiding globals is still a good idea?
Should I be bending over backward to avoid them even though my project is fairly small? (eg ~1600 lines)
Should I be bending over backward to avoid them even though my project is fairly small? (eg ~1600 lines)
quote:
Original post by Moe
So how do professional games handle things like this? Do they use the pointer method and keep track of all the meshes to be loaded in an array or something?
I (re)use a linked list template to store all of the objects that I load dynamicly. So, anything that isn''t needed isn''t in RAM, and when I want it there I tell it to load it. Having a static set of "containers" normally isn''t a good idea, and arrays are too slow to resize, so linked lists are a good idea.
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement