diff options
author | don bright <hugh.m.bright@gmail.com> | 2013-01-24 03:11:14 (GMT) |
---|---|---|
committer | don bright <hugh.m.bright@gmail.com> | 2013-01-24 03:11:14 (GMT) |
commit | ed24425305d1404dc7ecfc227feddb9c0c56a66f (patch) | |
tree | 43aa9e094b02891ce4d1b28a3f2a9e3ab61caddb /src/system-gl.cc | |
parent | 009baca90428399d4e3540bff18510ef51a28454 (diff) |
add system-gl.cc
Diffstat (limited to 'src/system-gl.cc')
-rw-r--r-- | src/system-gl.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/system-gl.cc b/src/system-gl.cc new file mode 100644 index 0000000..2e3f3bc --- /dev/null +++ b/src/system-gl.cc @@ -0,0 +1,50 @@ + +/* OpenGL helper functions */ + +#include <iostream> +#include <sstream> +#include <string> +#include "system-gl.h" +#include <boost/algorithm/string.hpp> + +using namespace std; +using namespace boost; + +string glew_dump(bool dumpall) +{ + stringstream out; + out << "GLEW version: " << glewGetString(GLEW_VERSION) << endl + << "GL Renderer: " << (const char *)glGetString(GL_RENDERER) << endl + << "GL Vendor: " << (const char *)glGetString(GL_VENDOR) << endl + << "OpenGL Version: " << (const char *)glGetString(GL_VERSION) << endl; + + out << "GL Extensions: " << endl; + if (dumpall) { + string extensions((const char *)glGetString(GL_EXTENSIONS)); + replace_all( extensions, " ", "\n " ); + out << " " << extensions << endl; + } + + out << "GL_ARB_framebuffer_object: " + << (glewIsSupported("GL_ARB_framebuffer_object") ? "yes" : "no") + << endl + << "GL_EXT_framebuffer_object: " + << (glewIsSupported("GL_EXT_framebuffer_object") ? "yes" : "no") + << endl + << "GL_EXT_packed_depth_stencil: " + << (glewIsSupported("GL_EXT_packed_depth_stencil") ? "yes" : "no") + << endl; + + return out.str(); +}; + +bool report_glerror(const char * function) +{ + GLenum tGLErr = glGetError(); + if (tGLErr != GL_NO_ERROR) { + cerr << "OpenGL error 0x" << hex << tGLErr << ": " << gluErrorString(tGLErr) << " after " << function << endl; + return true; + } + return false; +} + |