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

Method capture

Engine/source/gfx/screenshot.cpp:101–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void ScreenShot::capture( GuiCanvas *canvas )
102{
103 AssertFatal( mPending, "ScreenShot::capture() - The capture wasn't pending!" );
104
105 if ( mTiles == 1 )
106 {
107 _singleCapture( canvas );
108 return;
109 }
110
111 char filename[256];
112
113 Point2I canvasSize = canvas->getPlatformWindow()->getVideoMode().resolution;
114
115 // Calculate the real final size taking overlap in account
116 Point2I overlapPixels( canvasSize.x * mPixelOverlap.x, canvasSize.y * mPixelOverlap.y );
117
118 // Calculate the overlap to be used by the frustum tiling,
119 // so it properly expands the frustum to overlap the amount of pixels we want
120 mFrustumOverlap.x = ((F32)canvasSize.x/(canvasSize.x - overlapPixels.x*2)) * ((F32)overlapPixels.x/(F32)canvasSize.x);
121 mFrustumOverlap.y = ((F32)canvasSize.y/(canvasSize.y - overlapPixels.y*2)) * ((F32)overlapPixels.y/(F32)canvasSize.y);
122
123 //overlapPixels.set(0,0);
124 // Get a buffer to write a row of tiles into.
125 GBitmap *outBuffer = new GBitmap( canvasSize.x * mTiles - overlapPixels.x * mTiles * 2 , canvasSize.y - overlapPixels.y );
126
127 // Open up the file on disk.
128 dSprintf( filename, 256, "%s.%s", mFilename, "png" );
129 FileStream fs;
130 if ( !fs.open( filename, Torque::FS::File::Write ) )
131 Con::errorf( "ScreenShot::capture() - Failed to open output file '%s'!", filename );
132
133 // Open a PNG stream for the final image
134 DeferredPNGWriter pngWriter;
135 pngWriter.begin(outBuffer->getFormat(), outBuffer->getWidth(), canvasSize.y * mTiles - overlapPixels.y * mTiles * 2, fs, 0);
136
137 // Render each tile to generate a huge screenshot.
138 for( U32 ty=0; ty < mTiles; ty++ )
139 {
140 for( S32 tx=0; tx < mTiles; tx++ )
141 {
142 // Set the current tile offset for tileFrustum().
143 mCurrTile.set( tx, mTiles - ty - 1 );
144
145 // Let the canvas render the scene.
146 canvas->renderFrame( false );
147
148 // Now grab the current back buffer.
149 GBitmap *gb = _captureBackBuffer();
150
151 // The current GFX device couldn't capture the backbuffer or it's unable of doing so.
152 if (gb == NULL)
153 return;
154
155
156 // Copy the captured bitmap into its tile
157 // within the output bitmap.
158 const U32 inStride = gb->getWidth() * gb->getBytesPerPixel();

Callers 3

_updateMethod · 0.45
handlePaintEventMethod · 0.45

Calls 15

dSprintfFunction · 0.85
sBlendPixelRGB888Function · 0.85
getPlatformWindowMethod · 0.80
getWritableBitsMethod · 0.80
openMethod · 0.65
errorfFunction · 0.50
dMemcpyFunction · 0.50
beginMethod · 0.45
getFormatMethod · 0.45
getWidthMethod · 0.45
setMethod · 0.45
renderFrameMethod · 0.45

Tested by

no test coverage detected