1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-19 08:31:11 +00:00
CLK/Outputs/OpenGL/OpenGL.hpp
Ryan Carsten Schmidt 5e87692102 Include TargetConditionals.h where needed
Fixes build failure "error: 'TARGET_OS_IPHONE' is not defined, evaluates
to 0" on macOS with newer versions of clang.
2023-12-21 23:33:58 -06:00

62 lines
1.6 KiB
C++

//
// 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__
#include <TargetConditionals.h>
#if TARGET_OS_IPHONE
#else
// These remain so that I can, at least for now, build the kiosk version under macOS.
// They can be eliminated if and when Apple fully withdraws OpenGL support.
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#endif
#else
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
#endif
#ifndef NDEBUG
#define test_gl_error() { \
const auto error = glGetError(); \
if(error) { \
switch(error) { \
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 */