static int cl_videogmask;
static int cl_videobytesperpixel;
-static int cl_activevideos;
-static clvideo_t videoarray[ MAXCLVIDEOS ];
+static int cl_num_videos;
+static clvideo_t cl_videos[ MAXCLVIDEOS ];
static rtexturepool_t *cl_videotexturepool;
static clvideo_t *FindUnusedVid( void )
{
int i;
for( i = 1 ; i < MAXCLVIDEOS ; i++ )
- if( videoarray[ i ].state == CLVIDEO_UNUSED )
- return &videoarray[ i ];
+ if( cl_videos[ i ].state == CLVIDEO_UNUSED )
+ return &cl_videos[ i ];
return NULL;
}
return false;
}
- video->imagedata = Mem_Alloc( cl_mempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
+ video->imagedata = Mem_Alloc( cls.permanentmempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
- video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
+ video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, TEXF_ALWAYSPRECACHE, NULL );
// update starttime
video->starttime += realtime - video->lasttime;
video->cpif.width = dpvsimpledecode_getwidth( video->stream );
video->cpif.height = dpvsimpledecode_getheight( video->stream );
video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
- video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
+ video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, TEXF_ALWAYSPRECACHE, NULL );
- video->imagedata = Mem_Alloc( cl_mempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
+ video->imagedata = Mem_Alloc( cls.permanentmempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
return video;
}
video = OpenVideo( video, filename, name, owner );
// expand the active range to include the new entry
if (video)
- cl_activevideos = max(cl_activevideos, (int)(video - videoarray) + 1);
+ cl_num_videos = max(cl_num_videos, (int)(video - cl_videos) + 1);
return video;
}
static clvideo_t* CL_GetVideoBySlot( int slot )
{
- clvideo_t *video = &videoarray[ slot ];
+ clvideo_t *video = &cl_videos[ slot ];
if( video->suspended )
{
{
int i;
- for( i = 0 ; i < cl_activevideos ; i++ )
- if( videoarray[ i ].state != CLVIDEO_UNUSED
- && !strcmp( videoarray[ i ].cpif.name , name ) )
+ for( i = 0 ; i < cl_num_videos ; i++ )
+ if( cl_videos[ i ].state != CLVIDEO_UNUSED
+ && !strcmp( cl_videos[ i ].cpif.name , name ) )
break;
- if( i != cl_activevideos )
+ if( i != cl_num_videos )
return CL_GetVideoBySlot( i );
else
return NULL;
if( video->state == CLVIDEO_FIRSTFRAME )
destframe = 0;
else
- destframe = (realtime - video->starttime) * video->framerate;
+ destframe = (int)((realtime - video->starttime) * video->framerate);
if( destframe < 0 )
destframe = 0;
if( video->framenum < destframe ) {
return;
}
} while( video->framenum < destframe );
- R_UpdateTexture( video->cpif.tex, (unsigned char *)video->imagedata );
+ R_UpdateTexture( video->cpif.tex, (unsigned char *)video->imagedata, 0, 0, video->cpif.width, video->cpif.height );
}
}
int i;
clvideo_t *video;
- if (!cl_activevideos)
+ if (!cl_num_videos)
return;
- for( video = videoarray, i = 0 ; i < cl_activevideos ; video++, i++ )
+ for( video = cl_videos, i = 0 ; i < cl_num_videos ; video++, i++ )
if( video->state != CLVIDEO_UNUSED && !video->suspended )
{
if( realtime - video->lasttime > CLTHRESHOLD )
VideoFrame( video );
}
- if( videoarray->state == CLVIDEO_FIRSTFRAME )
+ if( cl_videos->state == CLVIDEO_FIRSTFRAME )
CL_VideoStop();
// reduce range to exclude unnecessary entries
- while (cl_activevideos > 0 && videoarray[cl_activevideos-1].state == CLVIDEO_UNUSED)
- cl_activevideos--;
+ while (cl_num_videos > 0 && cl_videos[cl_num_videos-1].state == CLVIDEO_UNUSED)
+ cl_num_videos--;
}
void CL_Video_Shutdown( void )
{
int i;
- for( i = 0 ; i < cl_activevideos ; i++ )
- CL_CloseVideo( &videoarray[ i ] );
+ for( i = 0 ; i < cl_num_videos ; i++ )
+ CL_CloseVideo( &cl_videos[ i ] );
}
void CL_PurgeOwner( int owner )
{
int i;
- for( i = 0 ; i < cl_activevideos ; i++ )
- if( videoarray[ i ].ownertag == owner )
- CL_CloseVideo( &videoarray[ i ] );
+ for( i = 0 ; i < cl_num_videos ; i++ )
+ if( cl_videos[ i ].ownertag == owner )
+ CL_CloseVideo( &cl_videos[ i ] );
}
int cl_videoplaying = false; // old, but still supported
{
Host_StartVideo();
- if( videoarray->state != CLVIDEO_UNUSED )
- CL_CloseVideo( videoarray );
- if( !OpenVideo( videoarray, filename, va( CLVIDEOPREFIX "%s", filename ), 0 ) )
+ if( cl_videos->state != CLVIDEO_UNUSED )
+ CL_CloseVideo( cl_videos );
+ if( !OpenVideo( cl_videos, filename, va( CLVIDEOPREFIX "%s", filename ), 0 ) )
return;
// expand the active range to include the new entry
- cl_activevideos = max(cl_activevideos, 1);
+ cl_num_videos = max(cl_num_videos, 1);
cl_videoplaying = true;
- CL_SetVideoState( videoarray, CLVIDEO_PLAY );
- CL_RestartVideo( videoarray );
+ CL_SetVideoState( cl_videos, CLVIDEO_PLAY );
+ CL_RestartVideo( cl_videos );
+}
+
+void CL_Video_KeyEvent( int key, int ascii, qboolean down )
+{
+ // only react to up events, to allow the user to delay the abortion point if it suddenly becomes interesting..
+ if( !down ) {
+ if( key == K_ESCAPE || key == K_ENTER || key == K_SPACE ) {
+ CL_VideoStop();
+ }
+ }
}
void CL_VideoStop(void)
{
cl_videoplaying = false;
- CL_CloseVideo( videoarray );
+ CL_CloseVideo( cl_videos );
}
static void CL_PlayVideo_f(void)
cl_videotexturepool = R_AllocTexturePool();
- for( video = videoarray, i = 0 ; i < cl_activevideos ; i++, video++ )
+ for( video = cl_videos, i = 0 ; i < cl_num_videos ; i++, video++ )
if( video->state != CLVIDEO_UNUSED && !video->suspended )
video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
- video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
+ video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, TEXF_ALWAYSPRECACHE, NULL );
}
static void cl_video_shutdown( void )
void CL_Video_Init( void )
{
- cl_activevideos = 0;
+ cl_num_videos = 0;
cl_videobytesperpixel = 4;
cl_videormask = BigLong(0xFF000000);
cl_videogmask = BigLong(0x00FF0000);