1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00
CLK/Outputs/OpenGL/OpenGL.hpp

58 lines
1.4 KiB
C++
Raw Normal View History

//
// OpenGL.h
// Clock Signal
//
// Created by Thomas Harte on 07/02/2016.
// Copyright 2016 Thomas Harte. All rights reserved.
//
#ifndef OpenGL_h
#define OpenGL_h
#include <cassert>
#include <iostream>
// TODO: figure out correct include paths for other platforms.
#ifdef __APPLE__
#if TARGET_OS_IPHONE
#else
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#endif
#else
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#endif
#ifndef NDEBUG
#define test_gl_error() { \
const auto error = glGetError(); \
if(error) { \
switch(error) { \
2019-02-19 02:37:07 +00:00
default: std::cerr << "Error " << error; break; \
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
#define test_gl_error() while(false) {}
#endif
#ifndef NDEBUG
#define test_gl(command, ...) do { command(__VA_ARGS__); test_gl_error(); } while(false);
#else
#define test_gl(command, ...) command(__VA_ARGS__)
#endif
#endif /* OpenGL_h */