summaryrefslogtreecommitdiff
path: root/tests/system-gl.cc
blob: 2e3f3bc08c19112b10e066f62a0e13bf24f2c410 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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;
}

contact: Jan Huwald // Impressum