]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
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 3b4781d7da56d9446b5b1969f332e5dc90c88208..ec09b5c33199be82a021f44cce6ae0de7ab97fcf 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 dc181b09356ab2d376a42a743ae1fb98b32987a2..08652af41bcc11091976fc477a264ec4aa745c9e 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 60888777e95abf467f0c3680fe7c15a78b9c43b9..afba2119b5a968068258cc641b3c919f72ef2248 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 92f90ab71b1ea788d305cf62e361f1dae6fb9f81..d132def1ccc33b0ef08e69c950541f823c97d5f9 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 9f887653e46227d66a7789186e9d3bde4d8eb9ac..4fdee6f4d80f2bb58ed8c2eaf284c2177158f39e 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 bd582cd174ffb1be3bd7d60c3c5ed713823496e5..24b6dfd80713ce72e5a37fe6c8a9bb29a0be7c24 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 881b48c5b36371f8fda156e654d50d9f4205c752..bcf79232cb848409f2e60b572253ac50c299226c 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 3c706f314cfb272fee0309213c18787def42c3b3..eff2960c3548c798be946ecbb25af4c7b1cc3f5b 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 e397f1559a70a61879a0742814c253cce1b5d3a2..af4131469d45cacdfb616ca9c5849e06db1f085f 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 83cad1ee0f8a5adcba63eb584e68c84065eba3df..3519fd940044dd983f9fb935f377e3f30bb9c976 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 31f98d8afabbf146efd1eeff26173f7fec7e4846..af966a96125e970e490578e2e380d4ee1e02e3e6 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 8021ade76fb46312c98e327eda819731a6ca02d7..541ef0439ea11ef6b811d0017c1c754b7a40c1d6 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 6ff74efc9e5b4005539498875164ac5e6b6f3b31..9316515c36796c934db814159defea43f948206f 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 1363733ca94b201fcaa37393ee7a15efa644bda6..d778e789b1eefbf4a6b30ca21cd302209bfc7ca9 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 e49ab57824221880474691f1dc9c7552be0e5533..388316ac4fab05051befc2f4d6c9dd6df5755490 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 8b722295c253fba57851b8776d7800d42b9938b1..d062a86a61dbfdc8813a6a5d4590c081617110d8 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 a00029bfc6658c8988b5903c49eb1a51a6194750..4d9153b4f5b9a9c366dac30c11ccd02d9d775676 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)