MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _singleCapture

Method _singleCapture

Engine/source/gfx/screenshot.cpp:218–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216
217
218void ScreenShot::_singleCapture( GuiCanvas *canvas )
219{
220 // Let the canvas render the scene.
221 canvas->renderFrame( false );
222
223 // Now grab the current back buffer.
224 GBitmap *bitmap = _captureBackBuffer();
225
226 // The current GFX device couldn't capture the backbuffer or it's unable of doing so.
227 if (bitmap == NULL)
228 return;
229
230 // We captured... clear the flag.
231 mPending = false;
232
233 // We gotta attach the extension ourselves.
234 char filename[256];
235 dSprintf( filename, 256, "%s.%s", mFilename, mWriteJPG ? "jpg" : "png" );
236
237 // Open up the file on disk.
238 FileStream fs;
239 if ( !fs.open( filename, Torque::FS::File::Write ) )
240 Con::errorf( "ScreenShot::_singleCapture() - Failed to open output file '%s'!", filename );
241 else
242 {
243 // Write it and close.
244 if ( mWriteJPG )
245 bitmap->writeBitmap( "jpg", fs );
246 else
247 bitmap->writeBitmap( "png", fs );
248
249 fs.close();
250 }
251
252 // Cleanup.
253 delete bitmap;
254}
255
256
257DefineEngineFunction( screenShot, void,

Callers

nothing calls this directly

Calls 6

dSprintfFunction · 0.85
writeBitmapMethod · 0.80
openMethod · 0.65
closeMethod · 0.65
errorfFunction · 0.50
renderFrameMethod · 0.45

Tested by

no test coverage detected