add DeviceLost and DeviceRestored functions to R_Modules system
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 2 Jul 2010 02:39:31 +0000 (02:39 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 2 Jul 2010 02:39:31 +0000 (02:39 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10263 d7cf8633-e32d-0410-b094-e92efae38249

17 files changed:
cl_gecko.c
cl_particles.c
cl_video.c
gl_backend.c
gl_draw.c
gl_rmain.c
gl_textures.c
model_shared.c
palette.c
r_explosion.c
r_lightning.c
r_modules.c
r_modules.h
r_shadow.c
r_sky.c
sbar.c
vid_sdl.c

index 3b4781d..ec09b5c 100644 (file)
@@ -869,7 +869,7 @@ void CL_Gecko_Init( void )
        Cmd_AddCommand( "gecko_injecttext", cl_gecko_injecttext_f, "Injects text into a browser" );
        Cmd_AddCommand( "gecko_movecursor", gl_gecko_movecursor_f, "Move the cursor to a certain position" );
 
-       R_RegisterModule( "CL_Gecko", cl_gecko_start, cl_gecko_shutdown, cl_gecko_newmap );
+       R_RegisterModule( "CL_Gecko", cl_gecko_start, cl_gecko_shutdown, cl_gecko_newmap, NULL, NULL );
 }
 
 void CL_Gecko_NavigateToURI( clgecko_t *instance, const char *URI ) {
index dc181b0..08652af 100644 (file)
@@ -2295,7 +2295,7 @@ void R_Particles_Init (void)
        Cvar_RegisterVariable(&r_drawparticles_drawdistance);
        Cvar_RegisterVariable(&r_drawdecals);
        Cvar_RegisterVariable(&r_drawdecals_drawdistance);
-       R_RegisterModule("R_Particles", r_part_start, r_part_shutdown, r_part_newmap);
+       R_RegisterModule("R_Particles", r_part_start, r_part_shutdown, r_part_newmap, NULL, NULL);
 }
 
 void R_DrawDecal_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
index 6088877..afba211 100644 (file)
@@ -612,6 +612,6 @@ void CL_Video_Init( void )
        Cvar_RegisterVariable(&cl_video_brightness);
        Cvar_RegisterVariable(&cl_video_stipple);
 
-       R_RegisterModule( "CL_Video", cl_video_start, cl_video_shutdown, cl_video_newmap );
+       R_RegisterModule( "CL_Video", cl_video_start, cl_video_shutdown, cl_video_newmap, NULL, NULL );
 }
 
index 92f90ab..d132def 100644 (file)
@@ -321,7 +321,7 @@ void gl_backend_init(void)
 
        Cmd_AddCommand("gl_vbostats", GL_VBOStats_f, "prints a list of all buffer objects (vertex data and triangle elements) and total video memory used by them");
 
-       R_RegisterModule("GL_Backend", gl_backend_start, gl_backend_shutdown, gl_backend_newmap);
+       R_RegisterModule("GL_Backend", gl_backend_start, gl_backend_shutdown, gl_backend_newmap, NULL, NULL);
 }
 
 void GL_SetMirrorState(qboolean state);
index 9f88765..4fdee6f 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -956,7 +956,7 @@ void GL_Draw_Init (void)
                        dpsnprintf(FONT_USER(i)->title, sizeof(FONT_USER(i)->title), "user%d", j++);
 
        Cmd_AddCommand ("loadfont",LoadFont_f, "loadfont function tganame loads a font; example: loadfont console gfx/veramono; loadfont without arguments lists the available functions");
-       R_RegisterModule("GL_Draw", gl_draw_start, gl_draw_shutdown, gl_draw_newmap);
+       R_RegisterModule("GL_Draw", gl_draw_start, gl_draw_shutdown, gl_draw_newmap, NULL, NULL);
 }
 
 void _DrawQ_Setup(void)
index bd582cd..24b6dfd 100644 (file)
@@ -6458,7 +6458,7 @@ void GL_Main_Init(void)
        Cvar_RegisterVariable(&r_framedatasize);
        if (gamemode == GAME_NEHAHRA || gamemode == GAME_TENEBRAE)
                Cvar_SetValue("r_fullbrights", 0);
-       R_RegisterModule("GL_Main", gl_main_start, gl_main_shutdown, gl_main_newmap);
+       R_RegisterModule("GL_Main", gl_main_start, gl_main_shutdown, gl_main_newmap, NULL, NULL);
 
        Cvar_RegisterVariable(&r_track_sprites);
        Cvar_RegisterVariable(&r_track_sprites_flags);
index 881b48c..bcf7923 100644 (file)
@@ -590,7 +590,7 @@ void R_Textures_Init (void)
        Cvar_RegisterVariable (&gl_texturecompression_reflectmask);
        Cvar_RegisterVariable (&gl_nopartialtextureupdates);
 
-       R_RegisterModule("R_Textures", r_textures_start, r_textures_shutdown, r_textures_newmap);
+       R_RegisterModule("R_Textures", r_textures_start, r_textures_shutdown, r_textures_newmap, NULL, NULL);
 }
 
 void R_Textures_Frame (void)
index 3c706f3..eff2960 100644 (file)
@@ -179,7 +179,7 @@ void Mod_Init (void)
 
 void Mod_RenderInit(void)
 {
-       R_RegisterModule("Models", mod_start, mod_shutdown, mod_newmap);
+       R_RegisterModule("Models", mod_start, mod_shutdown, mod_newmap, NULL, NULL);
 }
 
 void Mod_UnloadModel (dp_model_t *mod)
index e397f15..af41314 100644 (file)
--- a/palette.c
+++ b/palette.c
@@ -330,7 +330,7 @@ void Palette_Load(void)
 
 void Palette_Init(void)
 {
-       R_RegisterModule("Palette", Palette_Load, Palette_Shutdown, Palette_NewMap);
+       R_RegisterModule("Palette", Palette_Load, Palette_Shutdown, Palette_NewMap, NULL, NULL);
        Cvar_RegisterVariable(&r_colormap_palette);
        Palette_Load();
 }
index 83cad1e..3519fd9 100644 (file)
@@ -153,7 +153,7 @@ void R_Explosion_Init(void)
 #ifdef MAX_EXPLOSIONS
        Cvar_RegisterVariable(&r_drawexplosions);
 
-       R_RegisterModule("R_Explosions", r_explosion_start, r_explosion_shutdown, r_explosion_newmap);
+       R_RegisterModule("R_Explosions", r_explosion_start, r_explosion_shutdown, r_explosion_newmap, NULL, NULL);
 #endif
 }
 
index 31f98d8..af966a9 100644 (file)
@@ -174,7 +174,7 @@ void R_LightningBeams_Init(void)
        Cvar_RegisterVariable(&r_lightningbeam_color_green);
        Cvar_RegisterVariable(&r_lightningbeam_color_blue);
        Cvar_RegisterVariable(&r_lightningbeam_qmbtexture);
-       R_RegisterModule("R_LightningBeams", r_lightningbeams_start, r_lightningbeams_shutdown, r_lightningbeams_newmap);
+       R_RegisterModule("R_LightningBeams", r_lightningbeams_start, r_lightningbeams_shutdown, r_lightningbeams_newmap, NULL, NULL);
 }
 
 void R_CalcLightningBeamPolygonVertex3f(float *v, const float *start, const float *end, const float *offset)
index 8021ade..541ef04 100644 (file)
@@ -10,6 +10,8 @@ typedef struct rendermodule_s
        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(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)
@@ -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();
+       }
+}
+
index 6ff74ef..9316515 100644 (file)
@@ -3,11 +3,13 @@
 #define R_MODULES_H
 
 void R_Modules_Init(void);
-void R_RegisterModule(char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void));
+void R_RegisterModule(char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void));
 void R_Modules_Start(void);
 void R_Modules_Shutdown(void);
 void R_Modules_NewMap(void);
 void R_Modules_Restart(void);
+void R_Modules_DeviceLost(void);
+void R_Modules_DeviceRestored(void);
 
 #endif
 
index 1363733..d778e78 100644 (file)
@@ -761,7 +761,7 @@ void R_Shadow_Init(void)
        r_shadow_buffer_surfacesides = NULL;
        r_shadow_buffer_shadowtrispvs = NULL;
        r_shadow_buffer_lighttrispvs = NULL;
-       R_RegisterModule("R_Shadow", r_shadow_start, r_shadow_shutdown, r_shadow_newmap);
+       R_RegisterModule("R_Shadow", r_shadow_start, r_shadow_shutdown, r_shadow_newmap, NULL, NULL);
 }
 
 matrix4x4_t matrix_attenuationxyz =
diff --git a/r_sky.c b/r_sky.c
index e49ab57..388316a 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -454,6 +454,6 @@ void R_Sky_Init(void)
        Cvar_RegisterVariable (&r_skyscroll2);
        memset(&skyboxskinframe, 0, sizeof(skyboxskinframe));
        skyname[0] = 0;
-       R_RegisterModule("R_Sky", r_sky_start, r_sky_shutdown, r_sky_newmap);
+       R_RegisterModule("R_Sky", r_sky_start, r_sky_shutdown, r_sky_newmap, NULL, NULL);
 }
 
diff --git a/sbar.c b/sbar.c
index 8b72229..d062a86 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -407,7 +407,7 @@ void Sbar_Init (void)
                Cvar_RegisterVariable(&sbar_flagstatus_pos); // this cvar makes no sense in other games
        }
 
-       R_RegisterModule("sbar", sbar_start, sbar_shutdown, sbar_newmap);
+       R_RegisterModule("sbar", sbar_start, sbar_shutdown, sbar_newmap, NULL, NULL);
 }
 
 
index a00029b..4d9153b 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -488,7 +488,7 @@ void VID_Init (void)
        //Cvar_RegisterVariable(&joy_sensitivityroll);
        
 #ifdef SDL_R_RESTART
-       R_RegisterModule("SDL", sdl_start, sdl_shutdown, sdl_newmap);
+       R_RegisterModule("SDL", sdl_start, sdl_shutdown, sdl_newmap, NULL, NULL);
 #endif
 
        if (SDL_Init(SDL_INIT_VIDEO) < 0)