only apply the CFLAGS_CRYPTO to the crypto compile; helps in the Xonotic build system
[divverent/darkplaces.git] / cl_video.c
1
2 #include "quakedef.h"
3 #include "cl_dyntexture.h"
4 #include "cl_video.h"
5 #include "dpvsimpledecode.h"
6
7 // cvars
8 cvar_t cl_video_subtitles = {CVAR_SAVE, "cl_video_subtitles", "0", "show subtitles for videos (if they are presented)"};
9 cvar_t cl_video_subtitles_lines = {CVAR_SAVE, "cl_video_subtitles_lines", "4", "how many lines to occupy for subtitles"};
10 cvar_t cl_video_subtitles_textsize = {CVAR_SAVE, "cl_video_subtitles_textsize", "16", "textsize for subtitles"};
11 cvar_t cl_video_scale = {CVAR_SAVE, "cl_video_scale", "1", "scale of video, 1 = fullscreen, 0.75 - 3/4 of screen etc."};
12 cvar_t cl_video_scale_vpos = {CVAR_SAVE, "cl_video_scale_vpos", "0", "vertial align of scaled video, -1 is top, 1 is bottom"};
13 cvar_t cl_video_stipple = {CVAR_SAVE, "cl_video_stipple", "0", "draw interlacing-like effect on videos, similar to scr_stipple but static and used only with video playing."};
14 cvar_t cl_video_brightness = {CVAR_SAVE, "cl_video_brightness", "1", "brightness of video, 1 = fullbright, 0.75 - 3/4 etc."};
15
16 // constants (and semi-constants)
17 static int  cl_videormask;
18 static int  cl_videobmask;
19 static int  cl_videogmask;
20 static int      cl_videobytesperpixel;
21
22 static int cl_num_videos;
23 static clvideo_t cl_videos[ MAXCLVIDEOS ];
24 static rtexturepool_t *cl_videotexturepool;
25
26 static clvideo_t *FindUnusedVid( void )
27 {
28         int i;
29         for( i = 1 ; i < MAXCLVIDEOS ; i++ )
30                 if( cl_videos[ i ].state == CLVIDEO_UNUSED )
31                         return &cl_videos[ i ];
32         return NULL;
33 }
34
35 static qboolean OpenStream( clvideo_t * video )
36 {
37         const char *errorstring;
38         video->stream = dpvsimpledecode_open( video->filename, &errorstring);
39         if (!video->stream )
40         {
41                 Con_Printf("unable to open \"%s\", error: %s\n", video->filename, errorstring);
42                 return false;
43         }
44         return true;
45 }
46
47 static void VideoUpdateCallback(rtexture_t *rt, void *data) {
48         clvideo_t *video = (clvideo_t *) data;
49         R_UpdateTexture( video->cpif.tex, (unsigned char *)video->imagedata, 0, 0, video->cpif.width, video->cpif.height );
50 }
51
52 static void LinkVideoTexture( clvideo_t *video ) {
53         video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
54                 video->cpif.width, video->cpif.height, NULL, TEXTYPE_BGRA, TEXF_PERSISTENT, -1, NULL );
55         R_MakeTextureDynamic( video->cpif.tex, VideoUpdateCallback, video );
56         CL_LinkDynTexture( video->cpif.name, video->cpif.tex );
57 }
58
59 static void UnlinkVideoTexture( clvideo_t *video ) {
60         CL_UnlinkDynTexture( video->cpif.name );
61         // free the texture
62         R_FreeTexture( video->cpif.tex );
63         // free the image data
64         Mem_Free( video->imagedata );
65 }
66
67 static void SuspendVideo( clvideo_t * video )
68 {
69         if( video->suspended )
70                 return;
71         video->suspended = true;
72         UnlinkVideoTexture( video );
73         // if we are in firstframe mode, also close the stream
74         if( video->state == CLVIDEO_FIRSTFRAME )
75                 dpvsimpledecode_close( video->stream );
76 }
77
78 static qboolean WakeVideo( clvideo_t * video )
79 {
80         if( !video->suspended )
81                 return true;
82         video->suspended = false;
83
84         if( video->state == CLVIDEO_FIRSTFRAME )
85                 if( !OpenStream( video ) ) {
86                         video->state = CLVIDEO_UNUSED;
87                         return false;
88                 }
89
90         video->imagedata = Mem_Alloc( cls.permanentmempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
91         LinkVideoTexture( video );
92
93         // update starttime
94         video->starttime += realtime - video->lasttime;
95
96         return true;
97 }
98
99 static void LoadSubtitles( clvideo_t *video, const char *subtitlesfile )
100 {
101         char *subtitle_text;
102         const char *data;
103         float subtime, sublen;
104         int numsubs = 0;
105
106         if (gamemode == GAME_BLOODOMNICIDE)
107         {
108                 char overridename[MAX_QPATH];
109                 cvar_t *langcvar;
110
111                 langcvar = Cvar_FindVar("language");
112                 subtitle_text = NULL;
113                 if (langcvar)
114                 {
115                         dpsnprintf(overridename, sizeof(overridename), "script/locale/%s/%s", langcvar->string, subtitlesfile);
116                         subtitle_text = (char *)FS_LoadFile(overridename, cls.permanentmempool, false, NULL);
117                 }
118                 if (!subtitle_text)
119                         subtitle_text = (char *)FS_LoadFile(subtitlesfile, cls.permanentmempool, false, NULL);
120         }
121         else
122         {
123                 subtitle_text = (char *)FS_LoadFile(subtitlesfile, cls.permanentmempool, false, NULL);
124         }
125         if (!subtitle_text)
126         {
127                 Con_DPrintf( "LoadSubtitles: can't open subtitle file '%s'!\n", subtitlesfile );
128                 return;
129         }
130
131         // parse subtitle_text
132         // line is: x y "text" where
133         //    x - start time
134         //    y - seconds last (if 0 - last thru next sub, if negative - last to next sub - this amount of seconds)
135
136         data = subtitle_text;
137         for (;;)
138         {
139                 if (!COM_ParseToken_QuakeC(&data, false))
140                         break;
141                 subtime = atof( com_token );
142                 if (!COM_ParseToken_QuakeC(&data, false))
143                         break;
144                 sublen = atof( com_token );
145                 if (!COM_ParseToken_QuakeC(&data, false))
146                         break;
147                 if (!com_token[0])
148                         continue;
149                 // check limits
150                 if (video->subtitles == CLVIDEO_MAX_SUBTITLES)
151                 {
152                         Con_Printf("WARNING: CLVIDEO_MAX_SUBTITLES = %i reached when reading subtitles from '%s'\n", CLVIDEO_MAX_SUBTITLES, subtitlesfile);
153                         break;  
154                 }
155                 // add a sub
156                 video->subtitle_text[numsubs] = (char *) Mem_Alloc(cls.permanentmempool, strlen(com_token) + 1);
157                 memcpy(video->subtitle_text[numsubs], com_token, strlen(com_token) + 1);
158                 video->subtitle_start[numsubs] = subtime;
159                 video->subtitle_end[numsubs] = sublen;
160                 if (numsubs > 0) // make true len for prev sub, autofix overlapping subtitles
161                 {
162                         if (video->subtitle_end[numsubs-1] <= 0)
163                                 video->subtitle_end[numsubs-1] = max(video->subtitle_start[numsubs-1], video->subtitle_start[numsubs] + video->subtitle_end[numsubs-1]);
164                         else
165                                 video->subtitle_end[numsubs-1] = min(video->subtitle_start[numsubs-1] + video->subtitle_end[numsubs-1], video->subtitle_start[numsubs]);
166                 }
167                 numsubs++;
168                 // todo: check timing for consistency?
169         }
170         if (numsubs > 0) // make true len for prev sub, autofix overlapping subtitles
171         {
172                 if (video->subtitle_end[numsubs-1] <= 0)
173                         video->subtitle_end[numsubs-1] = 99999999; // fixme: make it end when video ends?
174                 else
175                         video->subtitle_end[numsubs-1] = video->subtitle_start[numsubs-1] + video->subtitle_end[numsubs-1];
176         }
177         Z_Free( subtitle_text );
178         video->subtitles = numsubs;
179 /*
180         Con_Printf( "video->subtitles: %i\n", video->subtitles );
181         for (numsubs = 0; numsubs < video->subtitles; numsubs++)
182                 Con_Printf( "  %03.2f %03.2f : %s\n", video->subtitle_start[numsubs], video->subtitle_end[numsubs], video->subtitle_text[numsubs] );
183 */
184 }
185
186 static clvideo_t* OpenVideo( clvideo_t *video, const char *filename, const char *name, int owner, const char *subtitlesfile )
187 {
188         strlcpy( video->filename, filename, sizeof(video->filename) );
189         video->ownertag = owner;
190         if( strncmp( name, CLVIDEOPREFIX, sizeof( CLVIDEOPREFIX ) - 1 ) )
191                 return NULL;
192         strlcpy( video->cpif.name, name, sizeof(video->cpif.name) );
193
194         if( !OpenStream( video ) )
195                 return NULL;
196
197         video->state = CLVIDEO_FIRSTFRAME;
198         video->framenum = -1;
199         video->framerate = dpvsimpledecode_getframerate( video->stream );
200         video->lasttime = realtime;
201         video->subtitles = 0;
202
203         video->cpif.width = dpvsimpledecode_getwidth( video->stream );
204         video->cpif.height = dpvsimpledecode_getheight( video->stream );
205         video->imagedata = Mem_Alloc( cls.permanentmempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
206         LinkVideoTexture( video );
207
208         // VorteX: load simple subtitle_text file
209         if (subtitlesfile[0])
210                 LoadSubtitles( video, subtitlesfile );
211
212         return video;
213 }
214
215 clvideo_t* CL_OpenVideo( const char *filename, const char *name, int owner, const char *subtitlesfile )
216 {
217         clvideo_t *video;
218         // sanity check
219         if( !name || !*name || strncmp( name, CLVIDEOPREFIX, sizeof( CLVIDEOPREFIX ) - 1 ) != 0 ) {
220                 Con_DPrintf( "CL_OpenVideo: Bad video texture name '%s'!\n", name );
221                 return NULL;
222         }
223
224         video = FindUnusedVid();
225         if( !video ) {
226                 Con_Printf( "CL_OpenVideo: unable to open video \"%s\" - video limit reached\n", filename );
227                 return NULL;
228         }
229         video = OpenVideo( video, filename, name, owner, subtitlesfile );
230         // expand the active range to include the new entry
231         if (video) {
232                 cl_num_videos = max(cl_num_videos, (int)(video - cl_videos) + 1);
233         }
234         return video;
235 }
236
237 static clvideo_t* CL_GetVideoBySlot( int slot )
238 {
239         clvideo_t *video = &cl_videos[ slot ];
240
241         if( video->suspended )
242         {
243                 if( !WakeVideo( video ) )
244                         return NULL;
245                 else if( video->state == CLVIDEO_RESETONWAKEUP )
246                         video->framenum = -1;
247         }
248
249         video->lasttime = realtime;
250
251         return video;
252 }
253
254 clvideo_t *CL_GetVideoByName( const char *name )
255 {
256         int i;
257
258         for( i = 0 ; i < cl_num_videos ; i++ )
259                 if( cl_videos[ i ].state != CLVIDEO_UNUSED
260                         &&      !strcmp( cl_videos[ i ].cpif.name , name ) )
261                         break;
262         if( i != cl_num_videos )
263                 return CL_GetVideoBySlot( i );
264         else
265                 return NULL;
266 }
267
268 void CL_SetVideoState( clvideo_t *video, clvideostate_t state )
269 {
270         if( !video )
271                 return;
272
273         video->lasttime = realtime;
274         video->state = state;
275         if( state == CLVIDEO_FIRSTFRAME )
276                 CL_RestartVideo( video );
277 }
278
279 void CL_RestartVideo( clvideo_t *video )
280 {
281         if( !video )
282                 return;
283
284         video->starttime = video->lasttime = realtime;
285         video->framenum = -1;
286
287         dpvsimpledecode_close( video->stream );
288         if( !OpenStream( video ) )
289                 video->state = CLVIDEO_UNUSED;
290 }
291
292 void CL_CloseVideo( clvideo_t * video )
293 {
294         int i;
295
296         if( !video || video->state == CLVIDEO_UNUSED )
297                 return;
298
299         if( !video->suspended || video->state != CLVIDEO_FIRSTFRAME )
300                 dpvsimpledecode_close( video->stream );
301         if( !video->suspended )
302                 UnlinkVideoTexture( video );
303         if (video->subtitles)
304         {
305                 for (i = 0; i < video->subtitles; i++)
306                         Z_Free( video->subtitle_text[i] );
307                 video->subtitles = 0;
308         }
309
310         video->state = CLVIDEO_UNUSED;
311 }
312
313 static void VideoFrame( clvideo_t *video )
314 {
315         int destframe;
316
317         if( video->state == CLVIDEO_FIRSTFRAME )
318                 destframe = 0;
319         else
320                 destframe = (int)((realtime - video->starttime) * video->framerate);
321         if( destframe < 0 )
322                 destframe = 0;
323         if( video->framenum < destframe ) {
324                 do {
325                         video->framenum++;
326                         if( dpvsimpledecode_video( video->stream, video->imagedata, cl_videormask,
327                                 cl_videogmask, cl_videobmask, cl_videobytesperpixel,
328                                 cl_videobytesperpixel * video->cpif.width )
329                                 ) { // finished?
330                                 CL_RestartVideo( video );
331                                 if( video->state == CLVIDEO_PLAY )
332                                                 video->state = CLVIDEO_FIRSTFRAME;
333                                 return;
334                         }
335                 } while( video->framenum < destframe );
336                 R_MarkDirtyTexture( video->cpif.tex );
337         }
338 }
339
340 void CL_Video_Frame( void ) // update all videos
341 {
342         int i;
343         clvideo_t *video;
344
345         if (!cl_num_videos)
346                 return;
347
348         for( video = cl_videos, i = 0 ; i < cl_num_videos ; video++, i++ )
349                 if( video->state != CLVIDEO_UNUSED && !video->suspended )
350                 {
351                         if( realtime - video->lasttime > CLTHRESHOLD )
352                                 SuspendVideo( video );
353                         else if( video->state == CLVIDEO_PAUSE )
354                                 video->starttime = realtime - video->framenum * video->framerate;
355                         else
356                                 VideoFrame( video );
357                 }
358
359         if( cl_videos->state == CLVIDEO_FIRSTFRAME )
360                 CL_VideoStop();
361
362         // reduce range to exclude unnecessary entries
363         while (cl_num_videos > 0 && cl_videos[cl_num_videos-1].state == CLVIDEO_UNUSED)
364                 cl_num_videos--;
365 }
366
367 void CL_Video_Shutdown( void )
368 {
369         int i;
370         for( i = 0 ; i < cl_num_videos ; i++ )
371                 CL_CloseVideo( &cl_videos[ i ] );
372 }
373
374 void CL_PurgeOwner( int owner )
375 {
376         int i;
377         for( i = 0 ; i < cl_num_videos ; i++ )
378                 if( cl_videos[ i ].ownertag == owner )
379                         CL_CloseVideo( &cl_videos[ i ] );
380 }
381
382 typedef struct
383 {
384         dp_font_t *font;
385         float x;
386         float y;
387         float width;
388         float height;
389         float alignment; // 0 = left, 0.5 = center, 1 = right
390         float fontsize;
391         float textalpha;
392 }
393 cl_video_subtitle_info_t;
394
395 float CL_DrawVideo_WordWidthFunc(void *passthrough, const char *w, size_t *length, float maxWidth)
396 {
397         cl_video_subtitle_info_t *si = (cl_video_subtitle_info_t *) passthrough;
398
399         if(w == NULL)
400                 return si->fontsize * si->font->maxwidth;
401         if(maxWidth >= 0)
402                 return DrawQ_TextWidth_UntilWidth(w, length, si->fontsize, si->fontsize, false, si->font, -maxWidth); // -maxWidth: we want at least one char
403         else if(maxWidth == -1)
404                 return DrawQ_TextWidth(w, *length, si->fontsize, si->fontsize, false, si->font);
405         else
406                 return 0;
407 }
408
409 int CL_DrawVideo_DisplaySubtitleLine(void *passthrough, const char *line, size_t length, float width, qboolean isContinuation)
410 {
411         cl_video_subtitle_info_t *si = (cl_video_subtitle_info_t *) passthrough;
412
413         int x = (int) (si->x + (si->width - width) * si->alignment);
414         if (length > 0)
415                 DrawQ_String(x, si->y, line, length, si->fontsize, si->fontsize, 1.0, 1.0, 1.0, si->textalpha, 0, NULL, false, si->font);
416         si->y += si->fontsize;
417         return 1;
418 }
419
420 int cl_videoplaying = false; // old, but still supported
421
422 void CL_DrawVideo(void)
423 {
424         clvideo_t *video;
425         float videotime;
426         cl_video_subtitle_info_t si;
427         int i;
428
429         if (!cl_videoplaying)
430                 return;
431
432         video = CL_GetVideoBySlot( 0 );
433
434         // fix cvars
435         if (cl_video_scale.value <= 0 || cl_video_scale.value > 1)
436                 Cvar_SetValueQuick( &cl_video_scale, 1);
437         if (cl_video_brightness.value <= 0 || cl_video_brightness.value > 10)
438                 Cvar_SetValueQuick( &cl_video_brightness, 1);
439
440         // draw black bg in case stipple is active or video is scaled
441         if (cl_video_stipple.integer || cl_video_scale.value != 1)
442                 DrawQ_Fill(0, 0, vid_conwidth.integer, vid_conheight.integer, 0, 0, 0, 1, 0);
443
444         // enable video-only polygon stipple (of global stipple is not active)
445         if (qglPolygonStipple && !scr_stipple.integer && cl_video_stipple.integer)
446         {
447                 GLubyte stipple[128];
448                 int i, s, width, parts;
449         
450                 s = cl_video_stipple.integer;
451                 parts = (s & 007);
452                 width = (s & 070) >> 3;
453                 qglEnable(GL_POLYGON_STIPPLE);CHECKGLERROR // 0x0B42
454                 for(i = 0; i < 128; ++i)
455                 {
456                         int line = i/4;
457                         stipple[i] = ((line >> width) & ((1 << parts) - 1)) ? 0x00 : 0xFF;
458                 }
459                 qglPolygonStipple(stipple);CHECKGLERROR
460         }
461
462         // draw video
463         if (cl_video_scale.value == 1)
464                 DrawQ_Pic(0, 0, &video->cpif, vid_conwidth.integer, vid_conheight.integer, cl_video_brightness.value, cl_video_brightness.value, cl_video_brightness.value, 1, 0);
465         else
466         {
467                 int px = (int)(vid_conwidth.integer * (1 - cl_video_scale.value) * 0.5);
468                 int py = (int)(vid_conheight.integer * (1 - cl_video_scale.value) * ((bound(-1, cl_video_scale_vpos.value, 1) + 1) / 2));
469                 int sx = (int)(vid_conwidth.integer * cl_video_scale.value);
470                 int sy = (int)(vid_conheight.integer * cl_video_scale.value);
471                 DrawQ_Pic(px, py, &video->cpif, sx , sy, cl_video_brightness.value, cl_video_brightness.value, cl_video_brightness.value, 1, 0);
472         }
473
474         // disable video-only stipple
475         if (qglPolygonStipple && !scr_stipple.integer && cl_video_stipple.integer)
476                 qglDisable(GL_POLYGON_STIPPLE);CHECKGLERROR
477
478         // VorteX: draw subtitle_text
479         if (!video->subtitles || !cl_video_subtitles.integer)
480                 return;
481
482         // find current subtitle
483         videotime = realtime - video->starttime;
484         for (i = 0; i < video->subtitles; i++)
485         {
486                 if (videotime >= video->subtitle_start[i] && videotime <= video->subtitle_end[i])
487                 {
488                         // found, draw it
489                         si.font = FONT_NOTIFY;
490                         si.x = vid_conwidth.integer * 0.1;
491                         si.y = vid_conheight.integer - (max(1, cl_video_subtitles_lines.value) * cl_video_subtitles_textsize.value);
492                         si.width = vid_conwidth.integer * 0.8;
493                         si.height = max(1, cl_video_subtitles_lines.integer) * cl_video_subtitles_textsize.value;
494                         si.alignment = 0.5;
495                         si.fontsize = cl_video_subtitles_textsize.value;
496                         si.textalpha = min(1, (videotime - video->subtitle_start[i])/0.5) * min(1, ((video->subtitle_end[i] - videotime)/0.3)); // fade in and fade out
497                         COM_Wordwrap(video->subtitle_text[i], strlen(video->subtitle_text[i]), 0, si.width, CL_DrawVideo_WordWidthFunc, &si, CL_DrawVideo_DisplaySubtitleLine, &si);
498                         break;
499                 }
500         }
501 }
502
503 void CL_VideoStart(char *filename, const char *subtitlesfile)
504 {
505         Host_StartVideo();
506
507         if( cl_videos->state != CLVIDEO_UNUSED )
508                 CL_CloseVideo( cl_videos );
509         // already contains video/
510         if( !OpenVideo( cl_videos, filename, va( CLDYNTEXTUREPREFIX "%s", filename ), 0, subtitlesfile ) )
511                 return;
512         // expand the active range to include the new entry
513         cl_num_videos = max(cl_num_videos, 1);
514
515         cl_videoplaying = true;
516
517         CL_SetVideoState( cl_videos, CLVIDEO_PLAY );
518         CL_RestartVideo( cl_videos );
519 }
520
521 void CL_Video_KeyEvent( int key, int ascii, qboolean down ) 
522 {
523         // only react to up events, to allow the user to delay the abortion point if it suddenly becomes interesting..
524         if( !down ) {
525                 if( key == K_ESCAPE || key == K_ENTER || key == K_SPACE ) {
526                         CL_VideoStop();
527                 }
528         }
529 }
530
531 void CL_VideoStop(void)
532 {
533         cl_videoplaying = false;
534
535         CL_CloseVideo( cl_videos );
536 }
537
538 static void CL_PlayVideo_f(void)
539 {
540         char name[MAX_QPATH], subtitlesfile[MAX_QPATH];
541
542         Host_StartVideo();
543
544         if (Cmd_Argc() < 2)
545         {
546                 Con_Print("usage: playvideo <videoname> [custom_subtitles_file]\nplays video named video/<videoname>.dpv\nif custom subtitles file is not presented\nit tries video/<videoname>.sub");
547                 return;
548         }
549
550         dpsnprintf(name, sizeof(name), "video/%s.dpv", Cmd_Argv(1));
551         if ( Cmd_Argc() > 2)
552                 CL_VideoStart(name, Cmd_Argv(2));
553         else
554         {
555                 dpsnprintf(subtitlesfile, sizeof(subtitlesfile), "video/%s.dpsubs", Cmd_Argv(1));
556                 CL_VideoStart(name, subtitlesfile);
557         }
558 }
559
560 static void CL_StopVideo_f(void)
561 {
562         CL_VideoStop();
563 }
564
565 static void cl_video_start( void )
566 {
567         int i;
568         clvideo_t *video;
569
570         cl_videotexturepool = R_AllocTexturePool();
571
572         for( video = cl_videos, i = 0 ; i < cl_num_videos ; i++, video++ )
573                 if( video->state != CLVIDEO_UNUSED && !video->suspended )
574                         LinkVideoTexture( video );
575 }
576
577 static void cl_video_shutdown( void )
578 {
579         // TODO: unlink video textures?
580         R_FreeTexturePool( &cl_videotexturepool );
581 }
582
583 static void cl_video_newmap( void )
584 {
585 }
586
587 void CL_Video_Init( void )
588 {
589         union
590         {
591                 unsigned char b[4];
592                 unsigned int i;
593         }
594         bgra;
595
596         cl_num_videos = 0;
597         cl_videobytesperpixel = 4;
598
599         // set masks in an endian-independent way (as they really represent bytes)
600         bgra.i = 0;bgra.b[0] = 0xFF;cl_videobmask = bgra.i;
601         bgra.i = 0;bgra.b[1] = 0xFF;cl_videogmask = bgra.i;
602         bgra.i = 0;bgra.b[2] = 0xFF;cl_videormask = bgra.i;
603
604         Cmd_AddCommand( "playvideo", CL_PlayVideo_f, "play a .dpv video file" );
605         Cmd_AddCommand( "stopvideo", CL_StopVideo_f, "stop playing a .dpv video file" );
606
607         Cvar_RegisterVariable(&cl_video_subtitles);
608         Cvar_RegisterVariable(&cl_video_subtitles_lines);
609         Cvar_RegisterVariable(&cl_video_subtitles_textsize);
610         Cvar_RegisterVariable(&cl_video_scale);
611         Cvar_RegisterVariable(&cl_video_scale_vpos);
612         Cvar_RegisterVariable(&cl_video_brightness);
613         Cvar_RegisterVariable(&cl_video_stipple);
614
615         R_RegisterModule( "CL_Video", cl_video_start, cl_video_shutdown, cl_video_newmap, NULL, NULL );
616 }
617