- if (cl_videoplaying)
- {
- drawqueuemesh_t mesh;
- float vertex3f[12];
- float texcoord2f[8];
- float color4f[16];
- float s1, t1, s2, t2, x1, y1, x2, y2;
- x1 = 0;
- y1 = 0;
- x2 = vid.conwidth;
- y2 = vid.conheight;
- R_FragmentLocation(cl_videotexture, NULL, NULL, &s1, &t1, &s2, &t2);
- texcoord2f[0] = s1;texcoord2f[1] = t1;
- texcoord2f[2] = s2;texcoord2f[3] = t1;
- texcoord2f[4] = s2;texcoord2f[5] = t2;
- texcoord2f[6] = s1;texcoord2f[7] = t2;
- R_FillColors(color4f, 4, 1, 1, 1, 1);
- vertex3f[ 0] = x1;vertex3f[ 1] = y1;vertex3f[ 2] = 0;
- vertex3f[ 3] = x2;vertex3f[ 4] = y1;vertex3f[ 5] = 0;
- vertex3f[ 6] = x2;vertex3f[ 7] = y2;vertex3f[ 8] = 0;
- vertex3f[ 9] = x1;vertex3f[10] = y2;vertex3f[11] = 0;
- mesh.texture = cl_videotexture;
- mesh.numtriangles = 2;
- mesh.numvertices = 4;
- mesh.element3i = polygonelements;
- mesh.vertex3f = vertex3f;
- mesh.texcoord2f = texcoord2f;
- mesh.color4f = color4f;
- DrawQ_Mesh(&mesh, 0);
- //DrawQ_Pic(0, 0, "engine_videoframe", vid.conwidth, vid.conheight, 1, 1, 1, 1, 0);
+ int destframe;
+
+ if( video->state == CLVIDEO_FIRSTFRAME )
+ destframe = 0;
+ else
+ destframe = (int)((realtime - video->starttime) * video->framerate);
+ if( destframe < 0 )
+ destframe = 0;
+ if( video->framenum < destframe ) {
+ do {
+ video->framenum++;
+ if( dpvsimpledecode_video( video->stream, video->imagedata, cl_videormask,
+ cl_videogmask, cl_videobmask, cl_videobytesperpixel,
+ cl_videobytesperpixel * video->cpif.width )
+ ) { // finished?
+ CL_RestartVideo( video );
+ if( video->state == CLVIDEO_PLAY )
+ video->state = CLVIDEO_FIRSTFRAME;
+ return;
+ }
+ } while( video->framenum < destframe );
+ R_MarkDirtyTexture( video->cpif.tex );