summaryrefslogtreecommitdiff
path: root/src/renderer/tr_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer/tr_init.c')
-rw-r--r--src/renderer/tr_init.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/renderer/tr_init.c b/src/renderer/tr_init.c
index a3fd2ca6..79c910d1 100644
--- a/src/renderer/tr_init.c
+++ b/src/renderer/tr_init.c
@@ -701,6 +701,51 @@ void R_ScreenShotJPEG_f (void) {
//============================================================================
/*
+==================
+RB_TakeVideoFrameCmd
+==================
+*/
+const void *RB_TakeVideoFrameCmd( const void *data )
+{
+ const videoFrameCommand_t *cmd;
+ int frameSize;
+ int i;
+
+ cmd = (const videoFrameCommand_t *)data;
+
+ qglReadPixels( 0, 0, cmd->width, cmd->height, GL_RGBA,
+ GL_UNSIGNED_BYTE, cmd->captureBuffer );
+
+ // gamma correct
+ if( ( tr.overbrightBits > 0 ) && glConfig.deviceSupportsGamma )
+ R_GammaCorrect( cmd->captureBuffer, cmd->width * cmd->height * 4 );
+
+ if( cmd->motionJpeg )
+ {
+ frameSize = SaveJPGToBuffer( cmd->encodeBuffer, 95,
+ cmd->width, cmd->height, cmd->captureBuffer );
+ }
+ else
+ {
+ frameSize = cmd->width * cmd->height * 4;
+
+ // Vertically flip the image
+ for( i = 0; i < cmd->height; i++ )
+ {
+ Com_Memcpy( &cmd->encodeBuffer[ i * ( cmd->width * 4 ) ],
+ &cmd->captureBuffer[ ( cmd->height - i - 1 ) * ( cmd->width * 4 ) ],
+ cmd->width * 4 );
+ }
+ }
+
+ ri.CL_WriteAVIVideoFrame( cmd->encodeBuffer, frameSize );
+
+ return (const void *)(cmd + 1);
+}
+
+//============================================================================
+
+/*
** GL_SetDefaultState
*/
void GL_SetDefaultState( void )
@@ -1202,5 +1247,7 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) {
re.GetEntityToken = R_GetEntityToken;
re.inPVS = R_inPVS;
+ re.TakeVideoFrame = RE_TakeVideoFrame;
+
return &re;
}