r_refdef.fogenabled = false;
}
+static r_refdef_scene_type_t r_currentscenetype = RST_CLIENT;
+static r_refdef_scene_t r_scenes_store[ RST_COUNT ];
+/*
+================
+R_SelectScene
+================
+*/
+void R_SelectScene( r_refdef_scene_type_t scenetype ) {
+ if( scenetype != r_currentscenetype ) {
+ // store the old scenetype
+ r_scenes_store[ r_currentscenetype ] = r_refdef.scene;
+ r_currentscenetype = scenetype;
+ // move in the new scene
+ r_refdef.scene = r_scenes_store[ r_currentscenetype ];
+ }
+}
+
+/*
+================
+R_GetScenePointer
+================
+*/
+r_refdef_scene_t * R_GetScenePointer( r_refdef_scene_type_t scenetype )
+{
+ // of course, we could also add a qboolean that provides a lock state and a ReleaseScenePointer function..
+ if( scenetype == r_currentscenetype ) {
+ return &r_refdef.scene;
+ } else {
+ return &r_scenes_store[ scenetype ];
+ }
+}
+
/*
================
R_RenderView
// init the normal menu now -> this will also correct the menu router pointers
MR_SetRouting (TRUE);
+ // reset the active scene, too (to be on the safe side ;))
+ R_SelectScene( RST_CLIENT );
+
Host_AbortCurrentFrame();
}
void MP_Draw (void)
{
// declarations that are needed right now
- extern r_refdef_scene_t menu_scene;
float oldquality;
- static r_refdef_scene_t clientscene;
- clientscene = r_refdef.scene;
- r_refdef.scene = menu_scene;
+
+ R_SelectScene( RST_MENU );
// reset the temp entities each frame
r_refdef.scene.numtempentities = 0;
PRVM_End;
+ // TODO: imo this should be moved into scene, too [1/27/2008 Andreas]
r_refdef.view.quality = oldquality;
- menu_scene = r_refdef.scene;
- r_refdef.scene = clientscene;
+ R_SelectScene( RST_CLIENT );
}
void MP_ToggleMenu_f (void)
const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
-r_refdef_scene_t menu_scene;
-
void VM_M_Cmd_Init(void)
{
+ r_refdef_scene_t *scene;
+
VM_Cmd_Init();
VM_Polygons_Reset();
- memset (&menu_scene, 0, sizeof (menu_scene));
+ scene = R_GetScenePointer( RST_MENU );
- menu_scene.maxtempentities = 128;
- menu_scene.tempentities = (entity_render_t*) Mem_Alloc(prog->progs_mempool, sizeof(entity_render_t) * menu_scene.maxtempentities);
+ memset (scene, 0, sizeof (*scene));
- menu_scene.maxentities = MAX_EDICTS + 256 + 512;
- menu_scene.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * menu_scene.maxentities);
+ scene->maxtempentities = 128;
+ scene->tempentities = (entity_render_t*) Mem_Alloc(prog->progs_mempool, sizeof(entity_render_t) * scene->maxtempentities);
+
+ scene->maxentities = MAX_EDICTS + 256 + 512;
+ scene->entities = (entity_render_t **)Mem_Alloc(prog->progs_mempool, sizeof(entity_render_t *) * scene->maxentities);
}
void VM_M_Cmd_Reset(void)
{
+ // note: the menu's render entities are automatically freed when the prog's pool is freed
+
//VM_Cmd_Init();
VM_Cmd_Reset();
VM_Polygons_Reset();
void R_UpdateVariables(void); // must call after setting up most of r_refdef, but before calling R_RenderView
void R_RenderView(void); // must set r_refdef and call R_UpdateVariables first
+typedef enum r_refdef_scene_type_s {
+ RST_CLIENT,
+ RST_MENU,
+ RST_COUNT
+} r_refdef_scene_type_t;
+
+void R_SelectScene( r_refdef_scene_type_t scenetype );
+r_refdef_scene_t * R_GetScenePointer( r_refdef_scene_type_t scenetype );
void R_SkinFrame_PrepareForPurge(void);
void R_SkinFrame_MarkUsed(skinframe_t *skinframe);