- if (cl_videoplaying)
- {
- drawqueuemesh_t mesh;
- int indices[6];
- float vertices[16];
- float texcoords[8];
- float colorsf[16];
- float s1, t1, s2, t2, x1, y1, x2, y2;
- indices[0] = 0;
- indices[1] = 1;
- indices[2] = 2;
- indices[3] = 0;
- indices[4] = 2;
- indices[5] = 3;
- x1 = 0;
- y1 = 0;
- x2 = vid.conwidth;
- y2 = vid.conheight;
- R_FragmentLocation(cl_videotexture, NULL, NULL, &s1, &t1, &s2, &t2);
- texcoords[0] = s1;texcoords[1] = t1;
- texcoords[2] = s2;texcoords[3] = t1;
- texcoords[4] = s2;texcoords[5] = t2;
- texcoords[6] = s1;texcoords[7] = t2;
- R_FillColors(colorsf, 4, r_colorscale, r_colorscale, r_colorscale, 1);
- vertices[ 0] = x1;vertices[ 1] = y1;vertices[ 2] = 0;vertices[ 3] = 0;
- vertices[ 4] = x2;vertices[ 5] = y1;vertices[ 6] = 0;vertices[ 7] = 0;
- vertices[ 8] = x2;vertices[ 9] = y2;vertices[10] = 0;vertices[11] = 0;
- vertices[12] = x1;vertices[13] = y2;vertices[14] = 0;vertices[15] = 0;
- mesh.texture = cl_videotexture;
- mesh.numindices = 6;
- mesh.numvertices = 4;
- mesh.indices = indices;
- mesh.vertices = vertices;
- mesh.texcoords = texcoords;
- mesh.colors = colorsf;
- 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 );