GL.hh 5.6 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
// 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#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
56
#else
57
58
59
60
61
// 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
Robert Menzel's avatar
Robert Menzel committed
62
63
64
65
66
67
68
69


// 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
70
#define ACGL_USE_GLEW
Robert Menzel's avatar
Robert Menzel committed
71
72

#if (defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR))
73
74
#   if (TARGET_OS_IPHONE == 1)
#       define PLATFORM_IOS
75
76
#       define ACGL_OPENGL_ES
#       undef ACGL_USE_GLEW // no glew support on iOS
77
78
79
80
81
82
83
#   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!
84
#       error "UNKNOWN mobile plattform! Dont know what to include!"
85
#       define ACGL_OPENGL_ES
86
#   endif
Robert Menzel's avatar
Robert Menzel committed
87
88
89
#endif

// we have allways to include glew first!
90
#ifdef ACGL_USE_GLEW
91
92
93
    // 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.
Robert Menzel's avatar
Robert Menzel committed
94
95
    #ifdef GLEW_STATIC
        #include "GL/glew.h"
Robert Menzel's avatar
Robert Menzel committed
96
97
98
99
100
101
102
    #else
        #if defined(__APPLE__) || defined(MACOSX)
            #include <OpenGL/glew.h>
        #else
            #include <GL/glew.h>
        #endif
    #endif // !GLEW_LOCAL_PATH
103
#endif // ACGL_USE_GLEW
Robert Menzel's avatar
Robert Menzel committed
104
105


Robert Menzel's avatar
Robert Menzel committed
106
107
#if (defined(__APPLE__) || defined(MACOSX))
#   ifdef ACGL_OPENGL_ES
108
//      iOS:
Robert Menzel's avatar
Robert Menzel committed
109
110
111
112
113
114
115
#       import <OpenGLES/ES1/gl.h>
#       import <OpenGLES/ES1/glext.h>
#       import <OpenGLES/ES2/gl.h>
#       import <OpenGLES/ES2/glext.h>
#   else
//      Desktop MacOS X:
#       if (!defined(ACGL_OPENGL_PROFILE_CORE) && (ACGL_OPENGL_VERSION > 21))
116
117
//          e.g. FULL_32 on Mac won't work
#           warning "Mac OS X only supports OpenGL >= 3.2 with Core profile only"
Robert Menzel's avatar
Robert Menzel committed
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#           define ACGL_OPENGL_PROFILE_CORE
#       endif
#       if defined(ACGL_OPENGL_PROFILE_CORE)
//          On MacOS X, theres only OpenGL up till 2.1 (<=10.6) or 3.2 (min. 10.7)
//          GLEW will define __gl_h_ and gl3.h will think we included gl.h and gl3.h,
//          to prevent a warning, define this flag:
#           define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
#               include <OpenGL/gl3.h>
#           undef GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
#       else
//          old MacOS X / OpenGL 2.1
#           include <OpenGL/gl.h>
#       endif
#   endif
Robert Menzel's avatar
Robert Menzel committed
132
#else
Robert Menzel's avatar
Robert Menzel committed
133
134
135
136
137
138
139
//  Windows/Linux
#   ifdef ACGL_OPENGL_PROFILE_CORE_HEADER
#       include <GL3/gl3.h>
#   else
//      in contrast to MacOS 10.7, the "old" header can be used for post 3.0 OpenGL!
#       include <GL/gl.h>
#   endif
Robert Menzel's avatar
Robert Menzel committed
140
141
#endif

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

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

151
#endif // ACGL_OPENGL_GL_HH