GL.hh 5.12 KB
Newer Older
Robert Menzel's avatar
Robert Menzel committed
1 2 3 4 5
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University         //
// All rights reserved.                                                       //
////////////////////////////////////////////////////////////////////////////////

6 7
#ifndef ACGL_OPENGL_GL_HH
#define ACGL_OPENGL_GL_HH
Robert Menzel's avatar
Robert Menzel committed
8 9 10 11 12 13 14 15 16

/*
 * This simple OpenGL wrapper is used to include OpenGL and GLEW
 * on different platforms.
 *
 * While these includes are located in a subdirectory of GL/ on most systems,
 * Apple hides them on different locations.
 *
 *
17 18 19 20 21 22 23 24 25 26 27 28 29
 * This wrapper can get configured with external defines:
 * QT_OPENGL_LIB               : include also the QT OpenGL headers and maybe use QT for other
 *                               graphics related stuff, like image loading for textures.
 * ACGL_OPENGL_SUPPORT_CORE_41 : (or other versions): basicly ACGL_OPENGL_PROFILE_* and ACGL_OPENGL_VERSION_*
 *                               combined!
 * ACGL_OPENGL_PROFILE_CORE    : CORE: only support for CORE functions, demands a CORE OpenGL context
 *                               FULL: support for CORE and deprecated functions
 * ACGL_OPENGL_VERSION_41      : (or other versions): minimal OpenGL version that can be assumed to be present.
 *                               The app can't run on older contexts and will probably terminate at startup.
 *                               Set this to a low version and it will run on lost machines
 *                               Set this to a high version and less run-time checks have to be performed to
 *                               work around missing features (like querying extensions etc).
 * ACGL_PLATFORM_DESKTOP       : DESKTOP vs. MOBILE plattform = GL vs. GL ES
Robert Menzel's avatar
Robert Menzel committed
30 31
 */

32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
// If there is a demand for a core context, we should include the new core headers as well,
// sadly, these are not very good supported yet, so this stays commented out for a while :-(
#ifdef ACGL_OPENGL_PROFILE_CORE
//#   define ACGL_OPENGL_PROFILE_CORE_HEADER
#endif

// 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
#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:
#                               define ACGL_OPENGL_VERSION_32
#                               define ACGL_OPENGL_VERSION 32
#                           endif
#                       endif
#                   endif
#               endif
#           endif
#       endif
#   endif
#endif

Robert Menzel's avatar
Robert Menzel committed
76 77 78 79 80 81 82 83 84 85 86


// If we're compiling for an Apple system we need this to distinquish between Mac and iOS:
#ifdef __APPLE__
#include <TargetConditionals.h>
#endif

// always include glew unless on iOS
#define USE_GLEW

#if (defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR))
87 88 89 90 91 92 93 94 95 96 97 98 99 100
#   if (TARGET_OS_IPHONE == 1)
#       define PLATFORM_IOS
#       define OPENGL_ES
#       undef USE_GLEW // no glew support on iOS
#   endif
#else
//  no iOS device...
#   ifdef ACGL_PLATFORM_MOBILE
//      ...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!
#       define OPENGL_ES
#   endif
Robert Menzel's avatar
Robert Menzel committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
#endif

// we have allways to include glew first!
#ifdef USE_GLEW
    #ifdef GLEW_LOCAL_PATH
        #include GLEW_LOCAL_PATH
    #else
        #if defined(__APPLE__) || defined(MACOSX)
            #include <OpenGL/glew.h>
        #else
            #include <GL/glew.h>
        #endif
    #endif // !GLEW_LOCAL_PATH
#endif // USE_GLEW


#if defined(__APPLE__) || defined(MACOSX)
    #ifdef OPENGL_ES
        #import <OpenGLES/ES1/gl.h>
        #import <OpenGLES/ES1/glext.h>
        #import <OpenGLES/ES2/gl.h>
        #import <OpenGLES/ES2/glext.h>
    #else
        // Desktop MacOS X:
125 126
        #ifdef ACGL_OPENGL_PROFILE_CORE
//          On MacOS X, all OpenGL versions >=3.2 are core and have to use the new headers:
Robert Menzel's avatar
Robert Menzel committed
127 128 129 130 131 132
            #include <GL3/gl3.h>
        #else
            #include <OpenGL/gl.h>
        #endif
    #endif
#else
133
    #ifdef ACGL_OPENGL_PROFILE_CORE_HEADER
Robert Menzel's avatar
Robert Menzel committed
134 135 136 137 138 139
        #include <GL3/gl3.h>
    #else
        #include <GL/gl.h>
    #endif
#endif

140 141
#ifdef QT_OPENGL_LIB
#   include <QtOpenGL/qgl.h>
Robert Menzel's avatar
Robert Menzel committed
142 143
#endif // USE_QT

144 145 146 147 148
//
// our own "extension":
//
#include <ACGL/OpenGL/EXT_direct_state_access.hh>

149
#endif // ACGL_OPENGL_GL_HH