18 #include "precompiled.h"
52 std::string str =
exts;
54 size_t idx = str.find_first_of(
" ");
55 while(idx != std::string::npos)
57 if(idx >= str.length() - 1)
63 ret += str.substr(0, idx);
65 str = str.substr(idx + 1);
66 idx = str.find_first_of(
" ");
75 TIMER(L
"write_sys_info");
91 wchar_t timestampBuf[100] = {
'\0'};
94 struct tm* t = gmtime(&seconds);
95 const size_t charsWritten = wcsftime(timestampBuf,
ARRAY_SIZE(timestampBuf), L
"(generated %Y-%m-%d %H:%M:%S UTC)", t);
97 fprintf(f,
"%ls\n\n", timestampBuf);
116 fprintf(f,
", %.2f MHz\n", cpuClock*1e-6);
118 fprintf(f,
", %.2f GHz\n", cpuClock*1e-9);
129 fprintf(f,
"Graphics Card : %ls\n", cardName.c_str());
130 fprintf(f,
"OpenGL Drivers : %s; %ls\n", glGetString(GL_VERSION), driverInfo.c_str());
134 fprintf(f,
"Sound Card : %ls\n",
snd_card);
139 if (!exts) exts =
"{unknown}";
140 fprintf(f,
"\nOpenGL Extensions: \n%s\n",
SplitExts(exts).c_str());
144 fprintf(f,
"\nSMBIOS: \n%s\n", smbios.c_str());
154 static wchar_t description[200];
182 const ssize_t bytes_written =
g_VFS->CreateFile(filename, file, da.
pos);
183 if(bytes_written > 0)
186 ret = (
Status)bytes_written;
203 const VfsPath basenameFormat(L
"screenshots/screenshot%04d");
209 const size_t bpp = 24;
214 if(extension == L
".bmp")
216 #if !CONFIG2_GLES // GLES doesn't support BGR
227 const size_t img_size = w * h * bpp/8;
231 GLvoid* img = buf.get() + hdr_size;
233 if(
tex_wrap(w, h, bpp, flags, buf, hdr_size, &t) < 0)
235 glReadPixels(0, 0, (GLsizei)w, (GLsizei)h, fmt, GL_UNSIGNED_BYTE, img);
240 g_VFS->GetRealPath(filename, realPath);
244 LOGERROR(L
"Error writing screenshot to '%ls'", filename.
string().c_str());
259 const VfsPath basenameFormat(L
"screenshots/screenshot%04d");
266 const int tile_w = 640, tile_h = 480;
269 const int img_w = tile_w*tiles, img_h = tile_h*tiles;
275 if(extension == L
".bmp")
277 #if !CONFIG2_GLES // GLES doesn't support BGR
283 const size_t img_size = img_w * img_h * bpp/8;
284 const size_t tile_size = tile_w * tile_h * bpp/8;
286 void* tile_data = malloc(tile_size);
292 shared_ptr<u8> img_buf;
296 GLvoid* img = img_buf.get() + hdr_size;
297 if(
tex_wrap(img_w, img_h, bpp, flags, img_buf, hdr_size, &t) < 0)
318 GLint oldReadBuffer, oldDrawBuffer;
319 glGetIntegerv(GL_READ_BUFFER, &oldReadBuffer);
320 glGetIntegerv(GL_DRAW_BUFFER, &oldDrawBuffer);
321 glDrawBuffer(GL_FRONT);
322 glReadBuffer(GL_FRONT);
330 for (
int tile_y = 0; tile_y < tiles; ++tile_y)
332 for (
int tile_x = 0; tile_x < tiles; ++tile_x)
344 glReadPixels(0, 0, tile_w, tile_h, fmt, GL_UNSIGNED_BYTE, tile_data);
345 for (
int y = 0; y < tile_h; ++y)
347 void* dest = (
char*)img + ((tile_y*tile_h + y) * img_w + (tile_x*tile_w)) * bpp/8;
348 void* src = (
char*)tile_data + y * tile_w * bpp/8;
349 memcpy(dest, src, tile_w * bpp/8);
359 glDrawBuffer(oldDrawBuffer);
360 glReadBuffer(oldReadBuffer);
375 g_VFS->GetRealPath(filename, realPath);
379 LOGERROR(L
"Error writing screenshot to '%ls'", filename.
string().c_str());
double os_cpu_ClockFrequency()
const char * cpu_IdentifierString()
#define WARN_IF_ERR(expression)
const OsPath & psLogDir()
void NextNumberedFilename(const PIVFS &fs, const VfsPath &pathnameFormat, size_t &nextNumber, VfsPath &nextPathname)
Determine the next available pathname with a given format.
std::string StringizeStructures(const Structures *structures)
static const uintptr_t maxSectorSize
const wchar_t * ErrorString(int err)
provides a memory range that can be expanded but doesn't waste physical memory or relocate itself...
size_t tex_hdr_size(const VfsPath &filename)
return the minimum header size (i.e.
void RenderGui(bool RenderingState)
enable/disable rendering of the GUI (intended mainly for screenshots)
indicates B and R pixel components are exchanged.
void SetCameraProjection()
void WriteScreenshot(const VfsPath &extension)
const Structures * GetStructures()
flags & TEX_ORIENTATION is a field indicating orientation, i.e.
static const wchar_t * HardcodedErrorString(int err)
size_t os_cpu_MemorySize()
std::wstring DriverInfo()
FILE * sys_OpenFile(const OsPath &pathname, const char *mode)
open a file like with fopen (but taking an OsPath argument).
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
const String & string() const
size_t os_cpu_MemoryAvailable()
double ClockFrequency()
measure the CPU clock frequency via rdtsc and timer_Time.
const char * ogl_ExtensionString()
get a list of all supported extensions.
CGame * g_Game
Globally accessible pointer to the CGame object.
i64 Status
Error handling system.
int uname(struct utsname *un)
shared_ptr< T > DummySharedPtr(T *ptr)
stores all data describing an image.
Status tex_write(Tex *t, const VfsPath &filename)
wchar_t snd_drv_ver[SND_DRV_VER_LEN]
sound driver identification and version.
wchar_t snd_card[SND_CARD_LEN]
description of sound card.
void SetViewPort(const SViewPort &viewport)
#define TIMER(description)
Measures the time taken to execute code up until end of the current scope; displays it via debug_prin...
static std::string SplitExts(const char *exts)
CGameView * GetView()
Get the pointer to the game view object.
void snd_detect()
detect sound card and set the above information.
void RenderLogger(bool RenderingState)
static Status AllocateAligned(shared_ptr< T > &p, size_t size, size_t alignment=cacheLineSize)
Path ChangeExtension(Path extension) const
wchar_t * StatusDescription(Status status, wchar_t *buf, size_t max_chars)
generate textual description of a Status.
Status tex_wrap(size_t w, size_t h, size_t bpp, size_t flags, const shared_ptr< u8 > &data, size_t ofs, Tex *t)
store the given image data into a Tex object; this will be as if it had been loaded via tex_load...
Status da_free(DynArray *da)
free all memory (address space + physical) that constitutes the given array.
void ogl_WarnIfError()
raise a warning (break into the debugger) if an OpenGL error is pending.
static size_t s_nextScreenshotNumber
void SetProjectionTile(int tiles, int tile_x, int tile_y)
void WriteBigScreenshot(const VfsPath &extension, int tiles)
void tex_free(Tex *t)
free all resources associated with the image and make further use of it impossible.
Status tex_encode(Tex *t, const OsPath &extension, DynArray *da)
encode a texture into a memory buffer in the desired file format.
#define RETURN_STATUS_IF_ERR(expression)