Original Post
Say in main.c we have the main loop that is something like
void gameloop(void) {
getinput();
...
drawEverythingThereistodraw();
}
(No, this is not how my code actually looks like).
Over in video.c we have
void initVideo(void) {
...
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, 1.0, 1.5, 20.0);
}
void drawEverythingThereistodraw(void) {
...
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(...);
// draw all the crap here
...
}
Now there are potentially many files that need to get things drawn. For example entity.c might have a draw function to (very surprisingly) draw the entity. So how should I arrange things so that this single function drawEverythingThereistodraw(void) calls all the necessary draw functions which are defined in many different files. A simple obvious would be to store a collection of function pointers say like
void (*drawitfunc)(/*parameters which need to be decided correctly the first time or else later problems*/);
So in some sense this is a data structure design question I guess. Then in drawEverythingThereistodraw I could just go through all the function pointers and call the draw functions they point to. In any event somehow all these draw calls need to be call through a single point it just makes sense that way I can''t see how you would organize your code in a different way that would be good.