Hi everyone! Here I am again with my best wishes of a happy new year to all the Codeguru people... and with a new happy problem for everyone! :-D

I'm using the GLUT (GL Utility Toolkit, for those who don't know about it) to develop a graphic application. The problem lies not in the graphic API nor in any matter related to graphics. The thing is, GLUT uses an approach based on callbacks: for each window a callback function is used for display, keyboard or mouse events, idle time, and all the stuff.

This kind of architecture is what makes it hard for me to use GLUT with C++. The problems I've encountered are basically two:

1) since the right thing to do would be to enclose most of the code inside of a class (including a singleton object of an Application class), I still need to specify a pointer to the function to be used as a callback, and this function should be a member function, which is hard to do (I found a couple of techniques, but I can't convince myself that they're worth the pain);

2) the usual approach I used in C was to create a "global" header file, which I would include in the main, and which would declare all the global variables (for example, the data structure that will contain the map of the world, since it will have to be available in multiple callback functions). Now, if I declare some objects this way (say, in "mainlib.h") and then include the header in more than one source file, the linker says that the object had already been declared in another object file.

Is there an easy way to overcome the limitations and the difficulties of such an architecture using C++?