DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
r_modules.c
Go to the documentation of this file.
1
2#include "quakedef.h"
3
4#define MAXRENDERMODULES 20
5
6typedef struct rendermodule_s
7{
8 int active; // set by start, cleared by shutdown
9 const char *name;
10 void(*start)(void);
11 void(*shutdown)(void);
12 void(*newmap)(void);
13 void(*devicelost)(void);
14 void(*devicerestored)(void);
15}
17
19
21{
22 Cmd_AddCommand(CF_CLIENT, "r_restart", R_Modules_Restart_f, "restarts renderer");
23}
24
25void R_RegisterModule(const char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void))
26{
27 int i;
28 for (i = 0;i < MAXRENDERMODULES;i++)
29 {
30 if (rendermodule[i].name == NULL)
31 break;
32 if (!strcmp(name, rendermodule[i].name))
33 {
34 Con_Printf("R_RegisterModule: module \"%s\" registered twice\n", name);
35 return;
36 }
37 }
38 if (i >= MAXRENDERMODULES)
39 Sys_Error("R_RegisterModule: ran out of renderer module slots (%i)", MAXRENDERMODULES);
42 rendermodule[i].start = start;
43 rendermodule[i].shutdown = shutdown;
44 rendermodule[i].newmap = newmap;
45 rendermodule[i].devicelost = devicelost;
46 rendermodule[i].devicerestored = devicerestored;
47}
48
50{
51 int i;
52 for (i = 0;i < MAXRENDERMODULES;i++)
53 {
54 if (rendermodule[i].name == NULL)
55 continue;
56 if (rendermodule[i].active)
57 {
58 Con_Printf ("R_Modules_Start: module \"%s\" already active\n", rendermodule[i].name);
59 continue;
60 }
61 Con_DPrintf("Starting render module \"%s\"\n", rendermodule[i].name);
64 }
65}
66
68{
69 int i;
70 // shutdown in reverse
71 for (i = MAXRENDERMODULES - 1;i >= 0;i--)
72 {
73 if (rendermodule[i].name == NULL)
74 continue;
75 if (!rendermodule[i].active)
76 continue;
77 Con_DPrintf("Stopping render module \"%s\"\n", rendermodule[i].name);
80 }
81}
82
84{
86 Con_Print("Restarting renderer\n");
90}
91
93{
94 int i;
96 for (i = 0;i < MAXRENDERMODULES;i++)
97 {
98 if (rendermodule[i].name == NULL)
99 continue;
100 if (!rendermodule[i].active)
101 continue;
103 }
105}
106
108{
109 int i;
110 for (i = 0;i < MAXRENDERMODULES;i++)
111 {
112 if (rendermodule[i].name == NULL)
113 continue;
114 if (!rendermodule[i].active)
115 continue;
116 if (!rendermodule[i].devicelost)
117 continue;
119 }
120}
121
122
124{
125 int i;
126 for (i = 0;i < MAXRENDERMODULES;i++)
127 {
128 if (rendermodule[i].name == NULL)
129 continue;
130 if (!rendermodule[i].active)
131 continue;
132 if (!rendermodule[i].devicerestored)
133 continue;
135 }
136}
137
void CL_StartVideo(void)
Definition cl_main.c:2786
void SCR_BeginLoadingPlaque(qbool startup)
Definition cl_screen.c:1838
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
Definition cmd.c:1661
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
Definition console.c:1504
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
Definition console.c:1544
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
void() predraw
void R_SkinFrame_PrepareForPurge(void)
Definition gl_rmain.c:2168
void R_SkinFrame_Purge(void)
Definition gl_rmain.c:2203
const GLchar * name
Definition glquake.h:601
void cmd(string command,...)
int i
#define NULL
Definition qtypes.h:12
void R_Modules_Shutdown(void)
Definition r_modules.c:67
rendermodule_t rendermodule[MAXRENDERMODULES]
Definition r_modules.c:18
void R_Modules_Start(void)
Definition r_modules.c:49
void R_Modules_NewMap(void)
Definition r_modules.c:92
void R_Modules_Restart_f(cmd_state_t *cmd)
Definition r_modules.c:83
void R_Modules_DeviceLost(void)
Definition r_modules.c:107
void R_RegisterModule(const char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void))
Definition r_modules.c:25
#define MAXRENDERMODULES
Definition r_modules.c:4
void R_Modules_Init(void)
Definition r_modules.c:20
void R_Modules_DeviceRestored(void)
Definition r_modules.c:123
command interpreter state - the tokenizing and execution of commands, as well as pointers to which cv...
Definition cmd.h:127
const char * name
Definition r_modules.c:9
void(* newmap)(void)
Definition r_modules.c:12
void(* devicerestored)(void)
Definition r_modules.c:14
void(* devicelost)(void)
Definition r_modules.c:13
void(* start)(void)
Definition r_modules.c:10
void(* shutdown)(void)
Definition r_modules.c:11
void Sys_Error(const char *error,...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN
Causes the entire program to exit ASAP.
Definition sys_shared.c:724