]> git.xonotic.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)
committerRudolf Polzer <divverent@alientrap.org>
Sat, 3 Jul 2010 14:49:42 +0000 (16:49 +0200)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10263 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=ac26fe8251232ec2eb02c89b9df3d07444063211

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 425ef129c57b9471688a6f705e40764e1218ed3b..0bc9cbc3aa5c24a61c79a61e6e3598e4081bafe0 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 fd0cff613e8df66800017698f81f271da3ed2e52..72f41165ad7a0ac83c3ce237490da39c7e21a1b6 100644 (file)
@@ -291,7 +291,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 02a5ac322a595933f83624556fc20a3f7edcaebb..f32caa9ac975e8eede237fcae32fb9f72025fdad 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 7c4256b751ac9b2e0a235d1ae06866725c64a2b7..debd6ee5703df46d445a3fbe8e90389313abf860 100644 (file)
@@ -6537,7 +6537,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 d20a0ecde3a13030582883ab6bbe42b06ba2c5ed..8b3939d8889294ab787acd1f777f46c3c20410db 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 307dab5a821ec186a226092652e39c0d315fa919..4accbdf1999c49c8a933abf68ed3466c265af34f 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 fcd75d76ba6607ce867fa8b4e9f9ec1d22c396e0..1c12a07b134d44df3990ba04150818f0e8260a09 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 a85706ca42860a6759d05cc7a0a103aab97f0782..2aed02fce0ed513eac26c33da2883abd1422d8bc 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 2f6b9ef81b2d068ba38bd425eb32ff36a71c8c87..fd7e9ecb8cc952b162d3ee2cdac1aebbfd60db2d 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)