Release Build Screenshot

#1
I wanna get screenshot by using C++. I know how to get it more or less.
But, does it work well with release mode? I've got no idea about it.
If anyone has, please let me know.

BTW, the way i wanna use is this:

Code: Select all

bool CD3D9Renderer::ScreenShotInternal(const char* filename, int width, EScreenShotMode eScreenShotMode)
{
// ignore invalid file access for screenshots
CDebugAllowFileAccess ignoreInvalidFileAccess;

bool bRet = true;
#if !defined(_RELEASE) || CRY_PLATFORM_WINDOWS || defined(ENABLE_LW_PROFILERS)
if (m_pRT && !m_pRT->IsRenderThread() && eScreenShotMode == eScreenShotMode_Normal)
m_pRT->FlushAndWait();

if (!gEnv || !gEnv->pSystem || gEnv->pSystem->IsQuitting() || gEnv->bIsOutOfMemory)
{
return false;
}

char path[ICryPak::g_nMaxPath];

path[sizeof(path) - 1] = 0;
gEnv->pCryPak->AdjustFileName(filename != 0 ? filename : "%USER%/ScreenShots", path, ICryPak::FLAGS_PATH_REAL | ICryPak::FLAGS_FOR_WRITING);

if (!filename)
{
size_t pathLen = strlen(path);
const char* pSlash = (!pathLen || path[pathLen - 1] == '/' || path[pathLen - 1] == '\\') ? "" : "/";

int i = 0;
for (; i < 10000; i++)
{
#if !CRY_PLATFORM_ORBIS
cry_sprintf(&path[pathLen], sizeof(path) - pathLen, "%sScreenShot%04d.jpg", pSlash, i);
#else
cry_sprintf(&path[pathLen], sizeof(path) - pathLen, "%sScreenShot%04d.tga", pSlash, i); // only TGA for now, ##FMT_CHK##
#endif
// HACK
// CaptureFrameBufferToFile must be fixed for 64-bit stereo screenshots
if (GetS3DRend().IsStereoEnabled())
{
#if !CRY_PLATFORM_ORBIS
cry_sprintf(&path[pathLen], sizeof(path) - pathLen, "%sScreenShot%04d_L.jpg", pSlash, i);
#else
cry_sprintf(&path[pathLen], sizeof(path) - pathLen, "%sScreenShot%04d_L.tga", pSlash, i); // only TGA for now, ##FMT_CHK##
#endif
}

FILE* fp = fxopen(path, "rb");
if (!fp)
break; // file doesn't exist

fclose(fp);
}

// HACK: DONT REMOVE Stereo3D will add _L and _R suffix later
#if !CRY_PLATFORM_ORBIS
cry_sprintf(&path[pathLen], sizeof(path) - pathLen, "%sScreenShot%04d.jpg", pSlash, i);
#else
cry_sprintf(&path[pathLen], sizeof(path) - pathLen, "%sScreenShot%04d.tga", pSlash, i); // only TGA for now, ##FMT_CHK##
#endif

if (i == 10000)
{
iLog->Log("Cannot save screen shot! Too many files.");
return false;
}
}

if (!gEnv->pCryPak->MakeDir(PathUtil::GetParentDirectory(path)))
{
iLog->Log("Cannot save screen shot! Failed to create directory \"%s\".", path);
return false;
}

// Log some stats
// -----------------------------------
iLog->LogWithType(ILog::eInputResponse, " ");
iLog->LogWithType(ILog::eInputResponse, "Screenshot: %s", path);
gEnv->pConsole->ExecuteString("goto"); // output position and angle, can be used with "goto" command from console

iLog->LogWithType(ILog::eInputResponse, " ");
iLog->LogWithType(ILog::eInputResponse, "$5Drawcalls: %d", gEnv->pRenderer->GetCurrentNumberOfDrawCalls());
iLog->LogWithType(ILog::eInputResponse, "$5FPS: %.1f (%.1f ms)", gEnv->pTimer->GetFrameRate(), gEnv->pTimer->GetFrameTime() * 1000.0f);

int nPolygons, nShadowVolPolys;
GetPolyCount(nPolygons, nShadowVolPolys);
iLog->LogWithType(ILog::eInputResponse, "Tris: %2d,%03d", nPolygons / 1000, nPolygons % 1000);

int nStreamCgfPoolSize = -1;
ICVar* pVar = gEnv->pConsole->GetCVar("e_StreamCgfPoolSize");
if (pVar)
nStreamCgfPoolSize = pVar->GetIVal();

if (gEnv->p3DEngine)
{
I3DEngine::SObjectsStreamingStatus objectsStreamingStatus;
gEnv->p3DEngine->GetObjectsStreamingStatus(objectsStreamingStatus);
iLog->LogWithType(ILog::eInputResponse, "CGF streaming: Loaded:%d InProg:%d All:%d Act:%d MemUsed:%2.2f MemReq:%2.2f PoolSize:%d",
objectsStreamingStatus.nReady, objectsStreamingStatus.nInProgress, objectsStreamingStatus.nTotal, objectsStreamingStatus.nActive, BYTES_TO_MB(objectsStreamingStatus.nAllocatedBytes), BYTES_TO_MB(objectsStreamingStatus.nMemRequired), nStreamCgfPoolSize);
}

STextureStreamingStats stats(false);
EF_Query(EFQ_GetTexStreamingInfo, stats);
const int iPercentage = int((float)stats.nCurrentPoolSize / stats.nMaxPoolSize * 100.f);
iLog->LogWithType(ILog::eInputResponse, "TexStreaming: MemUsed:%.2fMB(%d%%%%) PoolSize:%2.2fMB Trghput:%2.2fKB/s", BYTES_TO_MB(stats.nCurrentPoolSize), iPercentage, BYTES_TO_MB(stats.nMaxPoolSize), BYTES_TO_KB(stats.nThroughput));

gEnv->pConsole->ExecuteString("sys_RestoreSpec test*"); // to get useful debugging information about current spec settings to the log file
iLog->LogWithType(ILog::eInputResponse, " ");

if (GetS3DRend().IsStereoEnabled())
{
GetS3DRend().TakeScreenshot(path);
return true;
}

return CaptureFrameBufferToFile(path);

#endif//_RELEASE
return bRet;
}

Who is online

Users browsing this forum: No registered users and 1 guest