4 #define MAXRENDERMODULES 64
6 typedef struct rendermodule_s
8 int active; // set by start, cleared by shutdown
16 rendermodule_t rendermodule[MAXRENDERMODULES];
21 for (i = 0;i < MAXRENDERMODULES;i++)
22 rendermodule[i].name = NULL;
25 void R_RegisterModule(char *name, void(*start)(), void(*shutdown)(), void(*newmap)())
28 for (i = 0;i < MAXRENDERMODULES;i++)
30 if (rendermodule[i].name == NULL)
32 if (!strcmp(name, rendermodule[i].name))
33 Sys_Error("R_RegisterModule: module \"%s\" registered twice\n", name);
35 if (i >= MAXRENDERMODULES)
36 Sys_Error("R_RegisterModule: ran out of renderer module slots (%i)\n", MAXRENDERMODULES);
37 rendermodule[i].active = 0;
38 rendermodule[i].name = name;
39 rendermodule[i].start = start;
40 rendermodule[i].shutdown = shutdown;
41 rendermodule[i].newmap = newmap;
44 void R_Modules_Start ()
47 for (i = 0;i < MAXRENDERMODULES;i++)
49 if (rendermodule[i].name == NULL)
51 if (rendermodule[i].active)
52 Sys_Error("R_StartModules: module \"%s\" already active\n", rendermodule[i].name);
53 rendermodule[i].active = 1;
54 rendermodule[i].start();
58 void R_Modules_Shutdown ()
61 for (i = 0;i < MAXRENDERMODULES;i++)
63 if (rendermodule[i].name == NULL)
65 if (!rendermodule[i].active)
67 rendermodule[i].active = 0;
68 rendermodule[i].shutdown();
72 void R_Modules_Restart ()
78 void R_Modules_NewMap ()
81 for (i = 0;i < MAXRENDERMODULES;i++)
83 if (rendermodule[i].name == NULL)
85 if (!rendermodule[i].active)
87 rendermodule[i].newmap();