GL.hh 5.58 KB
Newer Older
1
2
3
4
5
/***********************************************************************
 * Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
 * All rights reserved.                                                *
 * Distributed under the terms of the MIT License (see LICENSE.TXT).   *
 **********************************************************************/
Robert Menzel's avatar
Robert Menzel committed
6

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

/*
 * 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.
 *
 *
18
19
20
21
22
23
24
25
26
27
28
29
30
 * 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
31
32
 */

33
34
35
36
37
38
39
40
// 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#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
57
#else
58
59
60
61
62
// 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
63
64
65
66
67
68
69
70


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

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

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


Robert Menzel's avatar
Robert Menzel committed
107
108
#if (defined(__APPLE__) || defined(MACOSX))
#   ifdef ACGL_OPENGL_ES
109
//      iOS:
Robert Menzel's avatar
Robert Menzel committed
110
111
112
113
114
115
116
#       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))
117
118
//          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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#           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
133
#else
Robert Menzel's avatar
Robert Menzel committed
134
135
136
137
138
139
140
//  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
141
142
#endif

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

148
#endif // ACGL_OPENGL_GL_HH