+ // calc brightness for fadein and fadeout effects
+ b = cl_video_brightness.value;
+ if (cl_video_fadein.value && (realtime - video->starttime) < cl_video_fadein.value)
+ b = pow((realtime - video->starttime)/cl_video_fadein.value, 2);
+ else if (cl_video_fadeout.value && ((video->starttime + video->framenum * video->framerate) - realtime) < cl_video_fadeout.value)
+ b = pow(((video->starttime + video->framenum * video->framerate) - realtime)/cl_video_fadeout.value, 2);
+
+ // draw black bg in case stipple is active or video is scaled
+ 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)
+ {
+ GLubyte stipple[128];
+ int i, 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
+ }
+#endif
+
+ // draw video
+ if (v_glslgamma_video.value >= 1)
+ DrawQ_SuperPic(px, py, &video->cpif, sx, sy, st[0], st[1], b, b, b, 1, st[2], st[3], b, b, b, 1, st[4], st[5], b, b, b, 1, st[6], st[7], b, b, b, 1, 0);
+ else
+ {
+ DrawQ_SuperPic(px, py, &video->cpif, sx, sy, st[0], st[1], b, b, b, 1, st[2], st[3], b, b, b, 1, st[4], st[5], b, b, b, 1, st[6], st[7], b, b, b, 1, DRAWFLAG_NOGAMMA);
+ if (v_glslgamma_video.value > 0.0)
+ DrawQ_SuperPic(px, py, &video->cpif, 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;
+
+ // find current subtitle
+ videotime = realtime - video->starttime;
+ for (i = 0; i < video->subtitles; i++)
+ {
+ if (videotime >= video->subtitle_start[i] && videotime <= video->subtitle_end[i])
+ {
+ // found, draw it
+ si.font = FONT_NOTIFY;
+ si.x = vid_conwidth.integer * 0.1;
+ si.y = vid_conheight.integer - (max(1, cl_video_subtitles_lines.value) * cl_video_subtitles_textsize.value);
+ si.width = vid_conwidth.integer * 0.8;
+ si.height = max(1, cl_video_subtitles_lines.integer) * cl_video_subtitles_textsize.value;
+ si.alignment = 0.5;
+ si.fontsize = cl_video_subtitles_textsize.value;
+ 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
+ COM_Wordwrap(video->subtitle_text[i], strlen(video->subtitle_text[i]), 0, si.width, CL_DrawVideo_WordWidthFunc, &si, CL_DrawVideo_DisplaySubtitleLine, &si);
+ break;
+ }
+ }