summaryrefslogtreecommitdiff
path: root/src/system-gl.cc
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-02-21 05:02:44 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-02-21 05:02:44 (GMT)
commite3ecf26d45afd3511634a7e5d9e0e569c038f915 (patch)
tree4b0bcea1ed940cad9a685c644b813a6a772c2207 /src/system-gl.cc
parentfc2d9341fac6948716b328b75f3366313bd2545a (diff)
obj_rot + obj_trans -> Eigen::Vector. simplify glinfo dialog box.
Diffstat (limited to 'src/system-gl.cc')
-rw-r--r--src/system-gl.cc79
1 files changed, 59 insertions, 20 deletions
diff --git a/src/system-gl.cc b/src/system-gl.cc
index 2e3f3bc..0c436e5 100644
--- a/src/system-gl.cc
+++ b/src/system-gl.cc
@@ -1,40 +1,79 @@
/* OpenGL helper functions */
+#include <algorithm>
#include <iostream>
+#include <vector>
#include <sstream>
#include <string>
#include "system-gl.h"
#include <boost/algorithm/string.hpp>
+#include <boost/format.hpp>
using namespace std;
using namespace boost;
-string glew_dump(bool dumpall)
+double gl_version()
{
- 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;
- }
+ string tmp((const char*)glGetString( GL_VERSION ));
+ vector<string> strs;
+ split(strs, tmp, is_any_of("."));
+ stringstream out;
+ if ( strs.size() >= 2)
+ out << strs[0] << "." << strs[1];
+ else
+ out << "0.0";
+ double d;
+ out >> d;
+ return d;
+}
+
+string glew_extensions_dump()
+{
+ std::string tmp;
+ if ( gl_version() >= 3.0 ) {
+ GLint numexts = 0;
+ glGetIntegerv(GL_NUM_EXTENSIONS, &numexts);
+ for ( int i=0;i<numexts;i++ ) {
+ tmp += (const char *) glGetStringi(GL_EXTENSIONS, i);
+ tmp += " ";
+ }
+ } else {
+ tmp = (const char *) glGetString(GL_EXTENSIONS);
+ }
+ vector<string> extensions;
+ split( extensions, tmp, is_any_of(" "));
+ sort( extensions.begin(), extensions.end() );
+ stringstream out;
+ out << "GL Extensions:";
+ for ( int i=0;i<extensions.size();i++ ) out << extensions[i] << "\n";
+ return out.str();
+}
+
+string glew_dump()
+{
+ GLint rbits, gbits, bbits, abits, dbits, sbits;
+ glGetIntegerv(GL_RED_BITS, &rbits);
+ glGetIntegerv(GL_GREEN_BITS, &gbits);
+ glGetIntegerv(GL_BLUE_BITS, &bbits);
+ glGetIntegerv(GL_ALPHA_BITS, &abits);
+ glGetIntegerv(GL_DEPTH_BITS, &dbits);
+ glGetIntegerv(GL_STENCIL_BITS, &sbits);
- out << "GL_ARB_framebuffer_object: "
+ stringstream out;
+ out << "GLEW version: " << glewGetString(GLEW_VERSION)
+ << "\nOpenGL Version: " << (const char *)glGetString(GL_VERSION)
+ << "\nGL Renderer: " << (const char *)glGetString(GL_RENDERER)
+ << "\nGL Vendor: " << (const char *)glGetString(GL_VENDOR)
+ << boost::format("\nRGBA(%d%d%d%d), depth(%d), stencil(%d)") %
+ rbits % gbits % bbits % abits % dbits % sbits;
+ out << "\nGL_ARB_framebuffer_object: "
<< (glewIsSupported("GL_ARB_framebuffer_object") ? "yes" : "no")
- << endl
- << "GL_EXT_framebuffer_object: "
+ << "\nGL_EXT_framebuffer_object: "
<< (glewIsSupported("GL_EXT_framebuffer_object") ? "yes" : "no")
- << endl
- << "GL_EXT_packed_depth_stencil: "
+ << "\nGL_EXT_packed_depth_stencil: "
<< (glewIsSupported("GL_EXT_packed_depth_stencil") ? "yes" : "no")
- << endl;
-
+ << "\n";
return out.str();
};
contact: Jan Huwald // Impressum