mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Makes error reporting more communicative.
This commit is contained in:
parent
8ecf885629
commit
6b2e1fe62b
@ -9,6 +9,8 @@
|
|||||||
#ifndef OpenGL_h
|
#ifndef OpenGL_h
|
||||||
#define OpenGL_h
|
#define OpenGL_h
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
// TODO: figure out correct include paths for other platforms.
|
// TODO: figure out correct include paths for other platforms.
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
@ -22,14 +24,25 @@
|
|||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// To consider: might it be smarter to switch and log on error,
|
|
||||||
// rather than raising an exception? They're conventionally
|
|
||||||
// something you're permitted to ignore.
|
|
||||||
//
|
|
||||||
// (and, from that indecision, hence the pointless decision
|
|
||||||
// on whether to use an assert based on NDEBUG)
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#define test_gl_error() assert(!glGetError());
|
|
||||||
|
#define test_gl_error() { \
|
||||||
|
const auto error = glGetError(); \
|
||||||
|
if(error) { \
|
||||||
|
switch(error) { \
|
||||||
|
default: std::cerr << "Error " << error;\
|
||||||
|
case GL_INVALID_ENUM: std::cerr << "GL_INVALID_ENUM"; break; \
|
||||||
|
case GL_INVALID_VALUE: std::cerr << "GL_INVALID_VALUE"; break; \
|
||||||
|
case GL_INVALID_OPERATION: std::cerr << "GL_INVALID_OPERATION"; break; \
|
||||||
|
case GL_INVALID_FRAMEBUFFER_OPERATION: std::cerr << "GL_INVALID_FRAMEBUFFER_OPERATION"; break; \
|
||||||
|
case GL_OUT_OF_MEMORY: std::cerr << "GL_OUT_OF_MEMORY"; break; \
|
||||||
|
}; \
|
||||||
|
std::cerr << " at line " << __LINE__ << " in " << __FILE__ << std::endl; \
|
||||||
|
assert(false); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define test_gl_error() while(false) {}
|
#define test_gl_error() while(false) {}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user