Commit 3b09b419 authored by Robert Menzel's avatar Robert Menzel
Browse files

clean up in GL defines, more robust ACGL init

parent 5a849c11
......@@ -37,43 +37,28 @@
// To compare the OpenGL version number we define a new ACGL_OPENGL_VERSION XY define here
// analog to ACGL_OPENGL_VERSION_XY
#ifdef ACGL_OPENGL_VERSION_21
# define ACGL_OPENGL_VERSION 21
#if defined (ACGL_OPENGL_VERSION_21)
# define ACGL_OPENGL_VERSION 21
#elif defined (ACGL_OPENGL_VERSION_30)
# define ACGL_OPENGL_VERSION 30
#elif defined (ACGL_OPENGL_VERSION_31)
# define ACGL_OPENGL_VERSION 31
#elif defined (ACGL_OPENGL_VERSION_32)
# define ACGL_OPENGL_VERSION 32
#elif defined (ACGL_OPENGL_VERSION_33)
# define ACGL_OPENGL_VERSION 33
#elif defined (ACGL_OPENGL_VERSION_40)
# define ACGL_OPENGL_VERSION 40
#elif defined (ACGL_OPENGL_VERSION_41)
# define ACGL_OPENGL_VERSION 41
#elif defined (ACGL_OPENGL_VERSION_42)
# define ACGL_OPENGL_VERSION 42
#else
# ifdef ACGL_OPENGL_VERSION_30
# define ACGL_OPENGL_VERSION 30
# else
# ifdef ACGL_OPENGL_VERSION_31
# define ACGL_OPENGL_VERSION 31
# else
# ifdef ACGL_OPENGL_VERSION_32
# define ACGL_OPENGL_VERSION 32
# else
# ifdef ACGL_OPENGL_VERSION_33
# define ACGL_OPENGL_VERSION 33
# else
# ifdef ACGL_OPENGL_VERSION_40
# define ACGL_OPENGL_VERSION 40
# else
# ifdef ACGL_OPENGL_VERSION_41
# define ACGL_OPENGL_VERSION 41
# else
# ifdef ACGL_OPENGL_VERSION_42
# define ACGL_OPENGL_VERSION 42
# else
// failback:
# warning NO ACGL_OPENGL_VERSION_XY SET!
# define ACGL_OPENGL_VERSION_32
# define ACGL_OPENGL_VERSION 32
# endif
# endif
# endif
# endif
# endif
# endif
# endif
#endif
// failback:
#warning "NO ACGL_OPENGL_VERSION_XY SET! Default to 3.2"
#define ACGL_OPENGL_VERSION_32
#define ACGL_OPENGL_VERSION 32
#endif // version checks
// If we're compiling for an Apple system we need this to distinquish between Mac and iOS:
......@@ -96,13 +81,16 @@
// ...but mobile:
// maybe maemo or android: first one to program for these plattforms should add
// the correct includes here!
# error UNKNOWN mobile plattform! Dont know what to include!
# error "UNKNOWN mobile plattform! Dont know what to include!"
# define ACGL_OPENGL_ES
# endif
#endif
// we have allways to include glew first!
#ifdef ACGL_USE_GLEW
// if GLEW_STATIC is defined, GLEW gets linked statically. GLEW itself needs this define
// but for us its the sign that a local version of GLEW gets used, so we find it on
// GL/glew.h on every system.
#ifdef GLEW_STATIC
#include "GL/glew.h"
#else
......@@ -117,6 +105,7 @@
#if (defined(__APPLE__) || defined(MACOSX))
# ifdef ACGL_OPENGL_ES
// iOS:
# import <OpenGLES/ES1/gl.h>
# import <OpenGLES/ES1/glext.h>
# import <OpenGLES/ES2/gl.h>
......@@ -124,6 +113,8 @@
# else
// Desktop MacOS X:
# if (!defined(ACGL_OPENGL_PROFILE_CORE) && (ACGL_OPENGL_VERSION > 21))
// e.g. FULL_32 on Mac won't work
# warning "Mac OS X only supports OpenGL >= 3.2 with Core profile only"
# define ACGL_OPENGL_PROFILE_CORE
# endif
# if defined(ACGL_OPENGL_PROFILE_CORE)
......
......@@ -19,23 +19,17 @@ bool init(void)
#ifdef ACGL_USE_GLEW
# ifdef ACGL_OPENGL_PROFILE_CORE
glewExperimental = TRUE;
GLenum errorCode = glewInit();
glGetError(); // just to get silently rid of the invalid enum that's quite normal for glew on core context :-(
if (errorCode != GLEW_OK)
{
Utils::error() << "could not init GLEW!" << std::endl;
}
# endif
OpenGL::VertexArrayObject *vao = new OpenGL::VertexArrayObject();
vao->bind();
# else
GLenum errorCode = glewInit();
if ((errorCode != GLEW_OK) || (openGLCriticalErrorOccured())) {
Utils::error() << "could not init GLEW!" << std::endl;
#ifdef ACGL_OPENGL_PROFILE_CORE
Utils::error() << "Make sure your version of GLEW is compatible with core contexts (see glew branch coreprofile)" << std::endl;
#endif
return false;
}
# endif
#endif
#endif // GLEW
//
// check OpenGL version
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment