| 257 | } |
| 258 | |
| 259 | void RenderToSavePic(FRenderViewpoint& vp, FileWriter* file, int width, int height) |
| 260 | { |
| 261 | IntRect bounds; |
| 262 | bounds.left = 0; |
| 263 | bounds.top = 0; |
| 264 | bounds.width = width; |
| 265 | bounds.height = height; |
| 266 | auto& RenderState = *screen->RenderState(); |
| 267 | |
| 268 | // we must be sure the GPU finished reading from the buffer before we fill it with new data. |
| 269 | screen->WaitForCommands(false); |
| 270 | |
| 271 | // Switch to render buffers dimensioned for the savepic |
| 272 | screen->SetSaveBuffers(true); |
| 273 | screen->ImageTransitionScene(true); |
| 274 | |
| 275 | RenderState.SetVertexBuffer(screen->mVertexData); |
| 276 | screen->mVertexData->Reset(); |
| 277 | screen->mLights->Clear(); |
| 278 | screen->mViewpoints->Clear(); |
| 279 | |
| 280 | twodpsp.Clear(); |
| 281 | |
| 282 | RenderViewpoint(vp, &bounds, vp.FieldOfView.Degrees(), 1.333f, 1.333f, true, false); |
| 283 | |
| 284 | |
| 285 | int numpixels = width * height; |
| 286 | TArray<uint8_t> scr(numpixels * 3, true); |
| 287 | screen->CopyScreenToBuffer(width, height, scr.Data()); |
| 288 | |
| 289 | DoWriteSavePic(file, scr.Data(), width, height, screen->FlipSavePic()); |
| 290 | |
| 291 | // Switch back the screen render buffers |
| 292 | screen->SetViewportRects(nullptr); |
| 293 | screen->SetSaveBuffers(false); |
| 294 | } |
| 295 | |
| 296 | //=========================================================================== |
| 297 | // |
no test coverage detected