ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
system_headers.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef GRAPHICS_OPENGL_SYSTEM_HEADERS_H
23 #define GRAPHICS_OPENGL_SYSTEM_HEADERS_H
24 
25 #include "common/scummsys.h"
26 
27 // On macOS we only support GL contexts. The reason is that Apple's GL interface
28 // uses "void *" for GLhandleARB which is not type compatible with GLint. This
29 // kills our aliasing trick for extension functions and thus would force us to
30 // supply two different Shader class implementations or introduce other
31 // wrappers. macOS only supports GL contexts right now anyway (at least
32 // according to SDL2 sources), thus it is not much of an issue.
33 #if defined(MACOSX) && (!defined(USE_GLES_MODE) || USE_GLES_MODE != 0)
34 //#warning "Only forced OpenGL mode is supported on macOS. Overriding settings."
35 #undef USE_GLES_MODE
36 #define USE_GLES_MODE 0
37 #endif
38 
39 // We allow to force GL or GLES modes on compile time.
40 // For this the USE_GLES_MODE define is used. The following values represent
41 // the given selection choices:
42 // 0 - Force OpenGL context
43 // 1 - Force OpenGL ES context
44 // 2 - Force OpenGL ES 2.0 context
45 #ifdef USE_GLES_MODE
46  #define USE_FORCED_GL (USE_GLES_MODE == 0)
47  #define USE_FORCED_GLES (USE_GLES_MODE == 1)
48  #define USE_FORCED_GLES2 (USE_GLES_MODE == 2)
49 #else
50  #define USE_FORCED_GL 0
51  #define USE_FORCED_GLES 0
52  #define USE_FORCED_GLES2 0
53 #endif
54 
55 // Don't include any OpenGL stuff if we didn't enable it
56 #ifdef USE_OPENGL
57 #ifdef USE_GLAD
58 
59  #include "graphics/opengl/glad.h"
60 
61 #elif USE_FORCED_GLES2
62 
63  #define GL_GLEXT_PROTOTYPES
64  #if defined(IPHONE)
65  #include <OpenGLES/ES2/gl.h>
66  #include <OpenGLES/ES2/glext.h>
67  #else
68  #include <GLES2/gl2.h>
69  #include <GLES2/gl2ext.h>
70  #endif
71  #undef GL_GLEXT_PROTOTYPES
72 
73 #elif USE_FORCED_GLES
74 
75  #define GL_GLEXT_PROTOTYPES
76  #if defined(IPHONE)
77  #include <OpenGLES/ES1/gl.h>
78  #include <OpenGLES/ES1/glext.h>
79  #else
80  #include <GLES/gl.h>
81  #include <GLES/glext.h>
82  #endif
83  #undef GL_GLEXT_PROTOTYPES
84 
85 #endif
86 #endif
87 
88 #if !defined(GL_TEXTURE_MAX_LEVEL) && defined(GL_TEXTURE_MAX_LEVEL_APPLE)
89  #define GL_TEXTURE_MAX_LEVEL GL_TEXTURE_MAX_LEVEL_APPLE
90 #endif
91 
92 #if !defined(GL_BGRA) && defined(GL_BGRA_EXT)
93  #define GL_BGRA GL_BGRA_EXT
94 #endif
95 
96 #if !defined(GL_UNPACK_ROW_LENGTH)
97  // The Android SDK does not declare GL_UNPACK_ROW_LENGTH_EXT
98  #define GL_UNPACK_ROW_LENGTH 0x0CF2
99 #endif
100 
101 #if !defined(GL_MAX_SAMPLES)
102  // The Android SDK and SDL1 don't declare GL_MAX_SAMPLES
103  #define GL_MAX_SAMPLES 0x8D57
104 #endif
105 
106 #if !defined(GL_STACK_OVERFLOW)
107  #define GL_STACK_OVERFLOW 0x0503
108 #endif
109 
110 #if !defined(GL_STACK_UNDERFLOW)
111  #define GL_STACK_UNDERFLOW 0x0504
112 #endif
113 
114 #if !defined(GL_CLAMP_TO_BORDER)
115  #define GL_CLAMP_TO_BORDER 0x812D
116 #endif
117 
118 #if !defined(GL_DRAW_FRAMEBUFFER_BINDING)
119  #define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6
120 #endif
121 
122 #endif