MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / CaptureRenderToFile

Method CaptureRenderToFile

neo/renderer/RenderSystem.cpp:926–958  ·  view source on GitHub ↗

============== CaptureRenderToFile ============== */

Source from the content-addressed store, hash-verified

924==============
925*/
926void idRenderSystemLocal::CaptureRenderToFile( const char *fileName, bool fixAlpha ) {
927 if ( !glConfig.isInitialized ) {
928 return;
929 }
930
931 renderCrop_t *rc = &renderCrops[currentRenderCrop];
932
933 guiModel->EmitFullScreen();
934 guiModel->Clear();
935 R_IssueRenderCommands();
936
937 qglReadBuffer( GL_BACK );
938
939 // include extra space for OpenGL padding to word boundaries
940 int c = ( rc->width + 3 ) * rc->height;
941 byte *data = (byte *)R_StaticAlloc( c * 3 );
942
943 qglReadPixels( rc->x, rc->y, rc->width, rc->height, GL_RGB, GL_UNSIGNED_BYTE, data );
944
945 byte *data2 = (byte *)R_StaticAlloc( c * 4 );
946
947 for ( int i = 0 ; i < c ; i++ ) {
948 data2[ i * 4 ] = data[ i * 3 ];
949 data2[ i * 4 + 1 ] = data[ i * 3 + 1 ];
950 data2[ i * 4 + 2 ] = data[ i * 3 + 2 ];
951 data2[ i * 4 + 3 ] = 0xff;
952 }
953
954 R_WriteTGA( fileName, data2, rc->width, rc->height, true );
955
956 R_StaticFree( data );
957 R_StaticFree( data2 );
958}
959
960
961/*

Callers 3

Event_CamShotMethod · 0.80
SaveGameMethod · 0.80
Event_CamShotMethod · 0.80

Calls 6

R_IssueRenderCommandsFunction · 0.85
R_StaticAllocFunction · 0.85
R_WriteTGAFunction · 0.85
R_StaticFreeFunction · 0.85
EmitFullScreenMethod · 0.80
ClearMethod · 0.45

Tested by

no test coverage detected