GL.hh 5.67 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


// 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
84
#define ACGL_USE_GLEW
Robert Menzel's avatar
Robert Menzel committed
85
86

#if (defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR))
87
88
#   if (TARGET_OS_IPHONE == 1)
#       define PLATFORM_IOS
89
90
#       define ACGL_OPENGL_ES
#       undef ACGL_USE_GLEW // no glew support on iOS
91
92
93
94
95
96
97
98
#   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!
99
#       define ACGL_OPENGL_ES
100
#   endif
Robert Menzel's avatar
Robert Menzel committed
101
102
103
#endif

// we have allways to include glew first!
104
#ifdef ACGL_USE_GLEW
Robert Menzel's avatar
Robert Menzel committed
105
106
    #ifdef GLEW_STATIC
        #include "GL/glew.h"
Robert Menzel's avatar
Robert Menzel committed
107
108
109
110
111
112
113
    #else
        #if defined(__APPLE__) || defined(MACOSX)
            #include <OpenGL/glew.h>
        #else
            #include <GL/glew.h>
        #endif
    #endif // !GLEW_LOCAL_PATH
114
#endif // ACGL_USE_GLEW
Robert Menzel's avatar
Robert Menzel committed
115
116


Robert Menzel's avatar
Robert Menzel committed
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#if (defined(__APPLE__) || defined(MACOSX))
#   ifdef ACGL_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:
#       if (!defined(ACGL_OPENGL_PROFILE_CORE) && (ACGL_OPENGL_VERSION > 21))
#           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
140
#else
Robert Menzel's avatar
Robert Menzel committed
141
142
143
144
145
146
147
//  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
148
149
#endif

150
151
#ifdef QT_OPENGL_LIB
#   include <QtOpenGL/qgl.h>
Robert Menzel's avatar
Robert Menzel committed
152
153
#endif // USE_QT

154
155
156
157
158
//
// our own "extension":
//
#include <ACGL/OpenGL/EXT_direct_state_access.hh>

159
#endif // ACGL_OPENGL_GL_HH