guess i amback,
yesterday i spent a few hours rewriting a small opengl program mainly to practice what we have been discussing.
for the most part, if i think about a situation in the program, i can just pass pointers to structs in a function, something like...
Code:
typedef struct Screen{
int high;
int wide;
}Screen
void do_screen_coords(Qscreen *screen){
#ifdef _WIN32
SDL_SysWMinfo i;
SDL_VERSION( &i.version );
if (!SDL_GetWMInfo(&i)) {
fprintf(stderr, "Failed to get WM Info!\n");
exit(1);
}
HWND hwnd = i.window;
screen->wide = (GetSystemMetrics( SM_CXSCREEN ))-5;
screen->high = (GetSystemMetrics( SM_CYSCREEN ))-60;
SetWindowPos(hwnd, HWND_TOP, 0, 0, screen->wide, screen->high, SWP_DRAWFRAME);
#else
screen->wide = 640;
screen->high = 480;
#endif
//fprintf (stdout,"old(%i,%i)\n", screen->wide,screen->high);
}
//then later
Qscreen initscreen;
do_screen_coords(&initscreen);
mywin = SDL_SetVideoMode(initscreen.wide, initscreen.high, 16, SDL_OPENGL |SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_RESIZABLE);
i am sure there are better ways to do this, but for the most part i was able to use similar concepts to above to pass information around in the program,
then i got to a part where i have a glRotate()&glTranslate(); that manipulates the matrix in one function in one file
and an eventhandler to manipulate the rotate/translate variables in another file;
these variables are stored as a struct instance
Code:
typedef struct WVector{
float tx,ty,tz;
float rx,ry;
}WVector;
extern WVector *G_move;
but i began reading up a bit more because i am sure i can do this differently and better without using the extern, basically what i am going to try later today after work, is using malloc,
but what i want to know is, if I allocate memory for a pointer to the WVector struct, would this memory portion be available across all files without using the extern declaration,up until i free it.
if so that would be great, any advice?am i understanding this correctly?