I do now know how to initialize structures on the global scope.
The following is a sample code:
#include
struct A
{
int x;
};
struct
And I am on Ubuntu 11.10, when I compile this program, I get the following errors: error: ‘a’ does not name a type
The compiler tells you with this message, that assignments to struct members can not happen in the global scope. If you want to initialize a
either write
struct A a = {6};
or using a newer syntax
struct A a = {.x = 6};
or do the initialization assignment early after program start (i.e. at the beginning of main).
BTW: This has nothing to do with GLUT or any other header. This is a language specification thing.
I am wondering how to pass a complex parameter to some callback function?
Well, in the case of GLUT callbacks it's going to be difficult, because GLUT doesn't allow you to specify user defined callback data. You could use the ffcall library to create in-situ closures which are then passed to GLUT. But there's the following to consider: As soon as you hit this wall, it's time to ditch GLUT. GLUT is not a requirement for OpenGL development and was never meant as a base for complex applications. So just don't use it then.