X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fvideo%2Fglutil.hpp;h=c1b45bea529824270b0da10e6481c7ff27af42ac;hb=9355ee0bb2a3cee71f3f9216c937da587f475f61;hp=bed97538d9874bf2bb2a9e66d9666576cf04b1ed;hpb=b08db3ab7e6d4447f8005dcf5a6c9e61a7f8e937;p=supertux.git diff --git a/src/video/glutil.hpp b/src/video/glutil.hpp index bed97538d..c1b45bea5 100644 --- a/src/video/glutil.hpp +++ b/src/video/glutil.hpp @@ -1,7 +1,7 @@ // $Id$ // -// SuperTux - A Jump'n Run -// Copyright (C) 2004 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -19,23 +19,89 @@ #ifndef __GLUTIL_HPP__ #define __GLUTIL_HPP__ +#include + +#ifdef HAVE_OPENGL + #include #include + +#ifdef MACOSX +#include +#include +#else +#ifdef GL_VERSION_ES_CM_1_0 +#include +#include +#else #include -#include +#include +#endif +#endif -static inline void assert_gl(const char* message) +static inline void check_gl_error(const char* message) { #ifdef DEBUG GLenum error = glGetError(); if(error != GL_NO_ERROR) { std::ostringstream msg; msg << "OpenGLError while '" << message << "': "; - //<< gluErrorString(error); + switch(error) { + case GL_INVALID_ENUM: + msg << "INVALID_ENUM: An unacceptable value is specified for an " + "enumerated argument."; + break; + case GL_INVALID_VALUE: + msg << "INVALID_VALUE: A numeric argument is out of range."; + break; + case GL_INVALID_OPERATION: + msg << "INVALID_OPERATION: The specified operation is not allowed " + "in the current state."; + break; + case GL_STACK_OVERFLOW: + msg << "STACK_OVERFLOW: This command would cause a stack overflow."; + break; + case GL_STACK_UNDERFLOW: + msg << "STACK_UNDERFLOW: This command would cause a stack underflow."; + break; + case GL_OUT_OF_MEMORY: + msg << "OUT_OF_MEMORY: There is not enough memory left to execute the " + "command."; + break; +#ifdef GL_TABLE_TOO_LARGE + case GL_TABLE_TOO_LARGE: + msg << "TABLE_TOO_LARGE: table is too large"; + break; +#endif + default: + msg << "Unknown error (code " << error << ")"; + } + throw std::runtime_error(msg.str()); } +#else + (void) message; #endif } +static inline void assert_gl(const char* message) +{ +#ifdef DEBUG + check_gl_error(message); +#else + (void) message; +#endif +} + +#else + +#define GLenum int +#define GLint int +#define GL_SRC_ALPHA 0 +#define GL_ONE_MINUS_SRC_ALPHA 1 +#define GL_RGBA 2 +#define GL_ONE 3 + #endif +#endif