diff options
Diffstat (limited to 'tests/OffscreenContext.mm')
-rw-r--r-- | tests/OffscreenContext.mm | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/OffscreenContext.mm b/tests/OffscreenContext.mm index 0c44d7d..990d3a4 100644 --- a/tests/OffscreenContext.mm +++ b/tests/OffscreenContext.mm @@ -2,9 +2,11 @@ #include "imageutils.h" #include "fbo.h" #include <iostream> +#include <sstream> #import <AppKit/AppKit.h> // for NSOpenGL... - +#include <CoreServices/CoreServices.h> +#include <sys/utsname.h> #define REPORTGLERROR(task) { GLenum tGLErr = glGetError(); if (tGLErr != GL_NO_ERROR) { std::cout << "OpenGL error " << tGLErr << " while " << task << "\n"; } } @@ -17,6 +19,29 @@ struct OffscreenContext fbo_t *fbo; }; +std::string offscreen_context_getinfo(OffscreenContext *ctx) +{ + std::stringstream out; + + struct utsname name; + uname(&name); + + SInt32 majorVersion,minorVersion,bugFixVersion; + + Gestalt(gestaltSystemVersionMajor, &majorVersion); + Gestalt(gestaltSystemVersionMinor, &minorVersion); + Gestalt(gestaltSystemVersionBugFix, &bugFixVersion); + + const char *arch = "unknown"; + if (sizeof(int*) == 4) arch = "32-bit"; + else if (sizeof(int*) == 8) arch = "64-bit"; + + out << "GL context creator: Cocoa / CGL\n" + << "PNG generator: Core Foundation\n" + << "OS info: Mac OS X " << majorVersion << "." << minorVersion << "." << bugFixVersion << " (" << name.machine << " kernel)\n" + << "Machine: " << arch << "\n"; + return out.str(); +} OffscreenContext *create_offscreen_context(int w, int h) { @@ -84,6 +109,7 @@ bool teardown_offscreen_context(OffscreenContext *ctx) */ bool save_framebuffer(OffscreenContext *ctx, const char *filename) { + if (!ctx || !filename) return false; // Read pixels from OpenGL int samplesPerPixel = 4; // R, G, B and A int rowBytes = samplesPerPixel * ctx->width; |