Changeset View
Changeset View
Standalone View
Standalone View
source/ps/Util.cpp
Show First 20 Lines • Show All 286 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
// Similar to WriteScreenshot, but generates an image of size 640*tiles x 480*tiles. | // Similar to WriteScreenshot, but generates an image of size 640*tiles x 480*tiles. | ||||
void WriteBigScreenshot(const VfsPath& extension, int tiles) | void WriteBigScreenshot(const VfsPath& extension, int tiles) | ||||
{ | { | ||||
// If the game hasn't started yet then use WriteScreenshot to generate the image. | // If the game hasn't started yet then use WriteScreenshot to generate the image. | ||||
if(g_Game == NULL){ WriteScreenshot(L".bmp"); return; } | if(!CGame::IsGameInitialised()){ WriteScreenshot(L".bmp"); return; } | ||||
// get next available numbered filename | // get next available numbered filename | ||||
// note: %04d -> always 4 digits, so sorting by filename works correctly. | // note: %04d -> always 4 digits, so sorting by filename works correctly. | ||||
const VfsPath basenameFormat(L"screenshots/screenshot%04d"); | const VfsPath basenameFormat(L"screenshots/screenshot%04d"); | ||||
const VfsPath filenameFormat = basenameFormat.ChangeExtension(extension); | const VfsPath filenameFormat = basenameFormat.ChangeExtension(extension); | ||||
VfsPath filename; | VfsPath filename; | ||||
vfs::NextNumberedFilename(g_VFS, filenameFormat, s_nextScreenshotNumber, filename); | vfs::NextNumberedFilename(g_VFS, filenameFormat, s_nextScreenshotNumber, filename); | ||||
Show All 37 Lines | #endif | ||||
} | } | ||||
ogl_WarnIfError(); | ogl_WarnIfError(); | ||||
// Resize various things so that the sizes and aspect ratios are correct | // Resize various things so that the sizes and aspect ratios are correct | ||||
{ | { | ||||
g_Renderer.Resize(tile_w, tile_h); | g_Renderer.Resize(tile_w, tile_h); | ||||
SViewPort vp = { 0, 0, tile_w, tile_h }; | SViewPort vp = { 0, 0, tile_w, tile_h }; | ||||
g_Game->GetView()->GetCamera()->SetViewPort(vp); | CGame::GetGame()->GetView()->GetCamera()->SetViewPort(vp); | ||||
g_Game->GetView()->SetCameraProjection(); | CGame::GetGame()->GetView()->SetCameraProjection(); | ||||
} | } | ||||
#if !CONFIG2_GLES | #if !CONFIG2_GLES | ||||
// Temporarily move everything onto the front buffer, so the user can | // Temporarily move everything onto the front buffer, so the user can | ||||
// see the exciting progress as it renders (and can tell when it's finished). | // see the exciting progress as it renders (and can tell when it's finished). | ||||
// (It doesn't just use SwapBuffers, because it doesn't know whether to | // (It doesn't just use SwapBuffers, because it doesn't know whether to | ||||
// call the SDL version or the Atlas version.) | // call the SDL version or the Atlas version.) | ||||
GLint oldReadBuffer, oldDrawBuffer; | GLint oldReadBuffer, oldDrawBuffer; | ||||
glGetIntegerv(GL_READ_BUFFER, &oldReadBuffer); | glGetIntegerv(GL_READ_BUFFER, &oldReadBuffer); | ||||
glGetIntegerv(GL_DRAW_BUFFER, &oldDrawBuffer); | glGetIntegerv(GL_DRAW_BUFFER, &oldDrawBuffer); | ||||
glDrawBuffer(GL_FRONT); | glDrawBuffer(GL_FRONT); | ||||
glReadBuffer(GL_FRONT); | glReadBuffer(GL_FRONT); | ||||
#endif | #endif | ||||
// Hide the cursor | // Hide the cursor | ||||
CStrW oldCursor = g_CursorName; | CStrW oldCursor = g_CursorName; | ||||
g_CursorName = L""; | g_CursorName = L""; | ||||
// Render each tile | // Render each tile | ||||
for (int tile_y = 0; tile_y < tiles; ++tile_y) | for (int tile_y = 0; tile_y < tiles; ++tile_y) | ||||
{ | { | ||||
for (int tile_x = 0; tile_x < tiles; ++tile_x) | for (int tile_x = 0; tile_x < tiles; ++tile_x) | ||||
{ | { | ||||
// Adjust the camera to render the appropriate region | // Adjust the camera to render the appropriate region | ||||
g_Game->GetView()->GetCamera()->SetProjectionTile(tiles, tile_x, tile_y); | CGame::GetGame()->GetView()->GetCamera()->SetProjectionTile(tiles, tile_x, tile_y); | ||||
RenderLogger(false); | RenderLogger(false); | ||||
RenderGui(false); | RenderGui(false); | ||||
Render(); | Render(); | ||||
RenderGui(true); | RenderGui(true); | ||||
RenderLogger(true); | RenderLogger(true); | ||||
// Copy the tile pixels into the main image | // Copy the tile pixels into the main image | ||||
Show All 15 Lines | #if !CONFIG2_GLES | ||||
glDrawBuffer(oldDrawBuffer); | glDrawBuffer(oldDrawBuffer); | ||||
glReadBuffer(oldReadBuffer); | glReadBuffer(oldReadBuffer); | ||||
#endif | #endif | ||||
// Restore the viewport settings | // Restore the viewport settings | ||||
{ | { | ||||
g_Renderer.Resize(g_xres, g_yres); | g_Renderer.Resize(g_xres, g_yres); | ||||
SViewPort vp = { 0, 0, g_xres, g_yres }; | SViewPort vp = { 0, 0, g_xres, g_yres }; | ||||
g_Game->GetView()->GetCamera()->SetViewPort(vp); | CGame::GetGame()->GetView()->GetCamera()->SetViewPort(vp); | ||||
g_Game->GetView()->SetCameraProjection(); | CGame::GetGame()->GetView()->SetCameraProjection(); | ||||
g_Game->GetView()->GetCamera()->SetProjectionTile(1, 0, 0); | CGame::GetGame()->GetView()->GetCamera()->SetProjectionTile(1, 0, 0); | ||||
} | } | ||||
if (tex_write(&t, filename) == INFO::OK) | if (tex_write(&t, filename) == INFO::OK) | ||||
{ | { | ||||
OsPath realPath; | OsPath realPath; | ||||
g_VFS->GetRealPath(filename, realPath); | g_VFS->GetRealPath(filename, realPath); | ||||
LOGMESSAGERENDER(g_L10n.Translate("Screenshot written to '%s'"), realPath.string8()); | LOGMESSAGERENDER(g_L10n.Translate("Screenshot written to '%s'"), realPath.string8()); | ||||
Show All 28 Lines |
Wildfire Games · Phabricator