X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=cl_video.c;h=5aebcd50a2dc06feecf44708dbaca9dd5bd04a40;hb=b1d6f1dfb96bedba50fbe394ca3f0c710f99381b;hp=7543c306196e20d3a16d17b052208ff79bea9a3f;hpb=0766a43538f3b526cba347157d5259bb3e5785a9;p=xonotic%2Fdarkplaces.git diff --git a/cl_video.c b/cl_video.c index 7543c306..5aebcd50 100644 --- a/cl_video.c +++ b/cl_video.c @@ -3,18 +3,18 @@ #include "cl_video.h" // cvars -cvar_t cl_video_subtitles = {CVAR_SAVE, "cl_video_subtitles", "0", "show subtitles for videos (if they are present)"}; -cvar_t cl_video_subtitles_lines = {CVAR_SAVE, "cl_video_subtitles_lines", "4", "how many lines to occupy for subtitles"}; -cvar_t cl_video_subtitles_textsize = {CVAR_SAVE, "cl_video_subtitles_textsize", "16", "textsize for subtitles"}; -cvar_t cl_video_scale = {CVAR_SAVE, "cl_video_scale", "1", "scale of video, 1 = fullscreen, 0.75 - 3/4 of screen etc."}; -cvar_t cl_video_scale_vpos = {CVAR_SAVE, "cl_video_scale_vpos", "0", "vertical align of scaled video, -1 is top, 1 is bottom"}; -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."}; -cvar_t cl_video_brightness = {CVAR_SAVE, "cl_video_brightness", "1", "brightness of video, 1 = fullbright, 0.75 - 3/4 etc."}; -cvar_t cl_video_keepaspectratio = {CVAR_SAVE, "cl_video_keepaspectratio", "0", "keeps aspect ratio of fullscreen videos, leaving black color on unfilled areas, a value of 2 let video to be stretched horizontally with top & bottom being sliced out"}; -cvar_t cl_video_fadein = {CVAR_SAVE, "cl_video_fadein", "0", "fading-from-black effect once video is started, in seconds"}; -cvar_t cl_video_fadeout = {CVAR_SAVE, "cl_video_fadeout", "0", "fading-to-black effect once video is ended, in seconds"}; - -cvar_t v_glslgamma_video = {CVAR_SAVE, "v_glslgamma_video", "1", "applies GLSL gamma to played video, could be a fraction, requires r_glslgamma_2d 1."}; +cvar_t cl_video_subtitles = {CVAR_CLIENT | CVAR_SAVE, "cl_video_subtitles", "0", "show subtitles for videos (if they are present)"}; +cvar_t cl_video_subtitles_lines = {CVAR_CLIENT | CVAR_SAVE, "cl_video_subtitles_lines", "4", "how many lines to occupy for subtitles"}; +cvar_t cl_video_subtitles_textsize = {CVAR_CLIENT | CVAR_SAVE, "cl_video_subtitles_textsize", "16", "textsize for subtitles"}; +cvar_t cl_video_scale = {CVAR_CLIENT | CVAR_SAVE, "cl_video_scale", "1", "scale of video, 1 = fullscreen, 0.75 - 3/4 of screen etc."}; +cvar_t cl_video_scale_vpos = {CVAR_CLIENT | CVAR_SAVE, "cl_video_scale_vpos", "0", "vertical align of scaled video, -1 is top, 1 is bottom"}; +cvar_t cl_video_stipple = {CVAR_CLIENT | CVAR_SAVE, "cl_video_stipple", "0", "draw interlacing-like effect on videos, similar to scr_stipple but static and used only with video playing."}; +cvar_t cl_video_brightness = {CVAR_CLIENT | CVAR_SAVE, "cl_video_brightness", "1", "brightness of video, 1 = fullbright, 0.75 - 3/4 etc."}; +cvar_t cl_video_keepaspectratio = {CVAR_CLIENT | CVAR_SAVE, "cl_video_keepaspectratio", "0", "keeps aspect ratio of fullscreen videos, leaving black color on unfilled areas, a value of 2 let video to be stretched horizontally with top & bottom being sliced out"}; +cvar_t cl_video_fadein = {CVAR_CLIENT | CVAR_SAVE, "cl_video_fadein", "0", "fading-from-black effect once video is started, in seconds"}; +cvar_t cl_video_fadeout = {CVAR_CLIENT | CVAR_SAVE, "cl_video_fadeout", "0", "fading-to-black effect once video is ended, in seconds"}; + +cvar_t v_glslgamma_video = {CVAR_CLIENT | CVAR_SAVE, "v_glslgamma_video", "1", "applies GLSL gamma to played video, could be a fraction, requires r_glslgamma_2d 1."}; // DPV stream decoder #include "dpvsimpledecode.h" @@ -64,7 +64,7 @@ static qboolean OpenStream( clvideo_t * video ) if (video->stream) return true; - Con_Printf("unable to open \"%s\", error: %s\n", video->filename, errorstring); + Con_Errorf("unable to open \"%s\", error: %s\n", video->filename, errorstring); return false; } @@ -137,7 +137,7 @@ static void LoadSubtitles( clvideo_t *video, const char *subtitlesfile ) char overridename[MAX_QPATH]; cvar_t *langcvar; - langcvar = Cvar_FindVar("language"); + langcvar = Cvar_FindVar(&cvars_all, "language", CVAR_CLIENT | CVAR_SERVER); subtitle_text = NULL; if (langcvar) { @@ -178,7 +178,7 @@ static void LoadSubtitles( clvideo_t *video, const char *subtitlesfile ) // check limits if (video->subtitles == CLVIDEO_MAX_SUBTITLES) { - Con_Printf("WARNING: CLVIDEO_MAX_SUBTITLES = %i reached when reading subtitles from '%s'\n", CLVIDEO_MAX_SUBTITLES, subtitlesfile); + Con_Warnf("WARNING: CLVIDEO_MAX_SUBTITLES = %i reached when reading subtitles from '%s'\n", CLVIDEO_MAX_SUBTITLES, subtitlesfile); break; } // add a sub @@ -253,7 +253,7 @@ clvideo_t* CL_OpenVideo( const char *filename, const char *name, int owner, cons video = FindUnusedVid(); if( !video ) { - Con_Printf( "CL_OpenVideo: unable to open video \"%s\" - video limit reached\n", filename ); + Con_Errorf( "CL_OpenVideo: unable to open video \"%s\" - video limit reached\n", filename ); return NULL; } video = OpenVideo( video, filename, name, owner, subtitlesfile ); @@ -533,25 +533,12 @@ void CL_DrawVideo(void) if (cl_video_stipple.integer || px != 0 || py != 0 || sx != vid_conwidth.integer || sy != vid_conheight.integer) DrawQ_Fill(0, 0, vid_conwidth.integer, vid_conheight.integer, 0, 0, 0, 1, 0); -#ifndef USE_GLES2 // enable video-only polygon stipple (of global stipple is not active) - if (qglPolygonStipple && !scr_stipple.integer && cl_video_stipple.integer) + if (!scr_stipple.integer && cl_video_stipple.integer) { - GLubyte stipple[128]; - int s, width, parts; - - s = cl_video_stipple.integer; - parts = (s & 007); - width = (s & 070) >> 3; - qglEnable(GL_POLYGON_STIPPLE);CHECKGLERROR // 0x0B42 - for(i = 0; i < 128; ++i) - { - int line = i/4; - stipple[i] = ((line >> width) & ((1 << parts) - 1)) ? 0x00 : 0xFF; - } - qglPolygonStipple(stipple);CHECKGLERROR + Con_Print("FIXME: cl_video_stipple not implemented\n"); + Cvar_SetValueQuick(&cl_video_stipple, 0); } -#endif // draw video if (v_glslgamma_video.value >= 1) @@ -563,14 +550,6 @@ void CL_DrawVideo(void) DrawQ_SuperPic(px, py, video->cachepic, sx, sy, st[0], st[1], b, b, b, v_glslgamma_video.value, st[2], st[3], b, b, b, v_glslgamma_video.value, st[4], st[5], b, b, b, v_glslgamma_video.value, st[6], st[7], b, b, b, v_glslgamma_video.value, 0); } -#ifndef USE_GLES2 - // disable video-only stipple - if (qglPolygonStipple && !scr_stipple.integer && cl_video_stipple.integer) - { - qglDisable(GL_POLYGON_STIPPLE);CHECKGLERROR - } -#endif - // VorteX: draw subtitle_text if (!video->subtitles || !cl_video_subtitles.integer) return; @@ -631,7 +610,7 @@ void CL_VideoStop(void) CL_CloseVideo( cl_videos ); } -static void CL_PlayVideo_f(void) +static void CL_PlayVideo_f(cmd_state_t *cmd) { char name[MAX_QPATH], subtitlesfile[MAX_QPATH]; const char *extension; @@ -641,27 +620,27 @@ static void CL_PlayVideo_f(void) if (COM_CheckParm("-benchmark")) return; - if (Cmd_Argc() < 2) + if (Cmd_Argc(cmd) < 2) { Con_Print("usage: playvideo [custom_subtitles_file]\nplays video named video/.dpv\nif custom subtitles file is not presented\nit tries video/.sub"); return; } - extension = FS_FileExtension(Cmd_Argv(1)); + extension = FS_FileExtension(Cmd_Argv(cmd, 1)); if (extension[0]) - dpsnprintf(name, sizeof(name), "video/%s", Cmd_Argv(1)); + dpsnprintf(name, sizeof(name), "video/%s", Cmd_Argv(cmd, 1)); else - dpsnprintf(name, sizeof(name), "video/%s.dpv", Cmd_Argv(1)); - if ( Cmd_Argc() > 2) - CL_VideoStart(name, Cmd_Argv(2)); + dpsnprintf(name, sizeof(name), "video/%s.dpv", Cmd_Argv(cmd, 1)); + if ( Cmd_Argc(cmd) > 2) + CL_VideoStart(name, Cmd_Argv(cmd, 2)); else { - dpsnprintf(subtitlesfile, sizeof(subtitlesfile), "video/%s.dpsubs", Cmd_Argv(1)); + dpsnprintf(subtitlesfile, sizeof(subtitlesfile), "video/%s.dpsubs", Cmd_Argv(cmd, 1)); CL_VideoStart(name, subtitlesfile); } } -static void CL_StopVideo_f(void) +static void CL_StopVideo_f(cmd_state_t *cmd) { CL_VideoStop(); } @@ -710,8 +689,8 @@ void CL_Video_Init( void ) bgra.i = 0;bgra.b[1] = 0xFF;cl_videogmask = bgra.i; bgra.i = 0;bgra.b[2] = 0xFF;cl_videormask = bgra.i; - Cmd_AddCommand( "playvideo", CL_PlayVideo_f, "play a .dpv video file" ); - Cmd_AddCommand( "stopvideo", CL_StopVideo_f, "stop playing a .dpv video file" ); + Cmd_AddCommand(&cmd_client, "playvideo", CL_PlayVideo_f, "play a .dpv video file" ); + Cmd_AddCommand(&cmd_client, "stopvideo", CL_StopVideo_f, "stop playing a .dpv video file" ); Cvar_RegisterVariable(&cl_video_subtitles); Cvar_RegisterVariable(&cl_video_subtitles_lines);