MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DoScreenshot

Function DoScreenshot

Descent3/game.cpp:1273–1322  ·  view source on GitHub ↗

Does a screenshot and tells the bitmap lib to save out the picture as a tga

Source from the content-addressed store, hash-verified

1271
1272// Does a screenshot and tells the bitmap lib to save out the picture as a tga
1273void DoScreenshot() {
1274 int count;
1275 char str[255], filename[255];
1276 CFILE *infile;
1277 int done = 0;
1278 int width = 640, height = 480;
1279
1280 if (UseHardware) {
1281 rendering_state rs;
1282 rend_GetRenderState(&rs);
1283 width = rs.screen_width;
1284 height = rs.screen_height;
1285 }
1286
1287 StopTime();
1288
1289 // Tell our renderer lib to take a screen shot
1290 auto screenshot = rend_Screenshot();
1291
1292 if (!screenshot || screenshot->getData() == nullptr) {
1293 AddHUDMessage(TXT_ERRSCRNSHT);
1294 return;
1295 }
1296
1297 // Find a valid filename
1298 count = 1;
1299 while (!done) {
1300 snprintf(str, sizeof(str), "Screenshot%.3d.png", count);
1301 ddio_MakePath(filename, Base_directory, str, NULL);
1302 infile = (CFILE *)cfopen(filename, "rb");
1303 if (infile == NULL) {
1304 done = 1;
1305 continue;
1306 } else
1307 cfclose(infile);
1308
1309 count++;
1310 if (count > 999)
1311 break;
1312 }
1313
1314 // Now save it
1315 screenshot->saveAsPNG(filename);
1316
1317 if (Demo_flags != DF_PLAYBACK) {
1318 AddHUDMessage(TXT_SCRNSHT, filename);
1319 }
1320
1321 StartTime();
1322}

Callers 5

ProcessNormalKeyFunction · 0.85
PostLevelResultsFunction · 0.85
TelComHandleAllEventsFunction · 0.85
DoUIFrameFunction · 0.85
DemoFrameFunction · 0.85

Calls 10

StopTimeFunction · 0.85
AddHUDMessageFunction · 0.85
cfopenFunction · 0.85
cfcloseFunction · 0.85
StartTimeFunction · 0.85
getDataMethod · 0.80
saveAsPNGMethod · 0.80
rend_GetRenderStateFunction · 0.50
rend_ScreenshotFunction · 0.50
ddio_MakePathFunction · 0.50

Tested by

no test coverage detected