2016-02-07 20:42:02 +00:00
|
|
|
//
|
|
|
|
// OpenGL.h
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 07/02/2016.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2016 Thomas Harte. All rights reserved.
|
2016-02-07 20:42:02 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef OpenGL_h
|
|
|
|
#define OpenGL_h
|
|
|
|
|
2019-02-19 02:29:39 +00:00
|
|
|
#include <cassert>
|
2019-02-18 16:13:54 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2016-02-07 20:42:02 +00:00
|
|
|
// TODO: figure out correct include paths for other platforms.
|
2016-03-09 03:53:29 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#if TARGET_OS_IPHONE
|
|
|
|
#else
|
|
|
|
#include <OpenGL/OpenGL.h>
|
|
|
|
#include <OpenGL/gl3.h>
|
2017-01-08 16:13:20 +00:00
|
|
|
#include <OpenGL/gl3ext.h>
|
2016-03-09 03:53:29 +00:00
|
|
|
#endif
|
2017-11-09 03:36:41 +00:00
|
|
|
#else
|
2017-11-10 03:04:49 +00:00
|
|
|
#define GL_GLEXT_PROTOTYPES
|
2017-11-09 03:36:41 +00:00
|
|
|
#include <GL/gl.h>
|
2020-05-28 01:20:43 +00:00
|
|
|
#include <GL/glext.h>
|
2016-03-09 03:53:29 +00:00
|
|
|
#endif
|
2016-02-07 20:42:02 +00:00
|
|
|
|
2019-02-18 15:29:40 +00:00
|
|
|
#ifndef NDEBUG
|
2019-02-18 16:13:54 +00:00
|
|
|
|
|
|
|
#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; \
|
2019-02-18 16:13:54 +00:00
|
|
|
}; \
|
|
|
|
std::cerr << " at line " << __LINE__ << " in " << __FILE__ << std::endl; \
|
|
|
|
assert(false); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
}
|
|
|
|
|
2019-02-18 15:29:40 +00:00
|
|
|
#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
|
|
|
|
|
2016-02-07 20:42:02 +00:00
|
|
|
#endif /* OpenGL_h */
|