]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - r_modules.c
common: Move infostring functions to new com_infostring.c
[xonotic/darkplaces.git] / r_modules.c
index 91221fc3923bc971b162135917c2d7e91e6803c7..904977146ece0e69771e7ebe2cb1a1838c4b5650 100644 (file)
@@ -1,15 +1,17 @@
 
 #include "quakedef.h"
 
-#define MAXRENDERMODULES 64
+#define MAXRENDERMODULES 20
 
 typedef struct rendermodule_s
 {
        int active; // set by start, cleared by shutdown
-       char *name;
+       const char *name;
        void(*start)(void);
        void(*shutdown)(void);
        void(*newmap)(void);
+       void(*devicelost)(void);
+       void(*devicerestored)(void);
 }
 rendermodule_t;
 
@@ -17,10 +19,10 @@ rendermodule_t rendermodule[MAXRENDERMODULES];
 
 void R_Modules_Init(void)
 {
-       Cmd_AddCommand("r_restart", R_Modules_Restart, "restarts renderer");
+       Cmd_AddCommand(CF_CLIENT, "r_restart", R_Modules_Restart_f, "restarts renderer");
 }
 
-void R_RegisterModule(char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void))
+void R_RegisterModule(const char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void))
 {
        int i;
        for (i = 0;i < MAXRENDERMODULES;i++)
@@ -40,6 +42,8 @@ void R_RegisterModule(char *name, void(*start)(void), void(*shutdown)(void), voi
        rendermodule[i].start = start;
        rendermodule[i].shutdown = shutdown;
        rendermodule[i].newmap = newmap;
+       rendermodule[i].devicelost = devicelost;
+       rendermodule[i].devicerestored = devicerestored;
 }
 
 void R_Modules_Start(void)
@@ -74,9 +78,9 @@ void R_Modules_Shutdown(void)
        }
 }
 
-void R_Modules_Restart(void)
+void R_Modules_Restart_f(cmd_state_t *cmd)
 {
-       Host_StartVideo();
+       CL_StartVideo();
        Con_Print("restarting renderer\n");
        R_Modules_Shutdown();
        R_Modules_Start();
@@ -97,3 +101,34 @@ void R_Modules_NewMap(void)
        R_SkinFrame_Purge();
 }
 
+void R_Modules_DeviceLost(void)
+{
+       int i;
+       for (i = 0;i < MAXRENDERMODULES;i++)
+       {
+               if (rendermodule[i].name == NULL)
+                       continue;
+               if (!rendermodule[i].active)
+                       continue;
+               if (!rendermodule[i].devicelost)
+                       continue;
+               rendermodule[i].devicelost();
+       }
+}
+
+
+void R_Modules_DeviceRestored(void)
+{
+       int i;
+       for (i = 0;i < MAXRENDERMODULES;i++)
+       {
+               if (rendermodule[i].name == NULL)
+                       continue;
+               if (!rendermodule[i].active)
+                       continue;
+               if (!rendermodule[i].devicerestored)
+                       continue;
+               rendermodule[i].devicerestored();
+       }
+}
+