X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=r_modules.c;h=818637e8467d67100f0e75e6291d403403a40c8e;hb=ea4908b279c9f7752cafa403a056dcc85626a553;hp=b1909685ef462b44020439e9eb4d07e5a30212ff;hpb=d159736a199e4043ed98cde48f6d5716ec40845c;p=xonotic%2Fdarkplaces.git diff --git a/r_modules.c b/r_modules.c index b1909685..818637e8 100644 --- a/r_modules.c +++ b/r_modules.c @@ -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; @@ -20,7 +22,7 @@ void R_Modules_Init(void) Cmd_AddCommand("r_restart", R_Modules_Restart, "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) @@ -76,6 +80,7 @@ void R_Modules_Shutdown(void) void R_Modules_Restart(void) { + Host_StartVideo(); Con_Print("restarting renderer\n"); R_Modules_Shutdown(); R_Modules_Start(); @@ -84,6 +89,7 @@ void R_Modules_Restart(void) void R_Modules_NewMap(void) { int i; + R_SkinFrame_PrepareForPurge(); for (i = 0;i < MAXRENDERMODULES;i++) { if (rendermodule[i].name == NULL) @@ -92,5 +98,37 @@ void R_Modules_NewMap(void) continue; rendermodule[i].newmap(); } + 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(); + } }