]> git.mxchange.org Git - simgear.git/blob - simgear/screen/extensions.hxx
26eb3d9d5adeddf0f8ecbef4cec780b40574b2d3
[simgear.git] / simgear / screen / extensions.hxx
1 /*
2  *
3  * Copyright (c) 2001 César Blecua Udías    All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included
13  * in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * CESAR BLECUA UDIAS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
20  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  *
23  */
24 #ifndef __SG_EXTENSIONS_HXX
25 #define __SG_EXTENSIONS_HXX 1
26
27 #if defined(__CYGWIN__)  /* && !defined(USING_X) */
28 #define WIN32
29 #endif
30
31 #if defined(WIN32)  /* MINGW and MSC predefine WIN32 */
32 # include <windows.h>
33 #endif
34
35 #if !defined(WIN32)
36 # include <dlfcn.h>
37 #endif
38
39 #include <GL/gl.h>
40
41
42 #if defined(__cplusplus)
43 extern "C" {
44 #endif
45
46 #ifndef APIENTRY
47 #define APIENTRY
48 #endif
49
50     // static bool SGSearchExtensionsString(char *extString, char *extName);
51 bool SGIsOpenGLExtensionSupported(char *extName);
52
53 #ifdef __APPLE__
54   // don't use an inline function for symbol lookup, since it is too big
55   void* macosxGetGLProcAddress(const char *func);
56 #endif
57
58 inline void (*SGLookupFunction(const char *func))()
59 {
60 #if defined( WIN32 )
61     return (void (*)()) wglGetProcAddress(func);
62
63 #elif defined( __APPLE__ )
64     return (void (*)()) macosxGetGLProcAddress(func);
65
66 #else // UNIX
67
68     // If the target system s UNIX and the ARB_get_proc_address
69     // GLX extension is *not* guaranteed to be supported. An alternative
70     // dlsym-based approach will be used instead.
71
72     void *libHandle;
73     void (*fptr)();
74     libHandle = dlopen("libGL.so", RTLD_LAZY);
75     fptr = (void (*)()) dlsym(libHandle, func);
76     dlclose(libHandle);
77     return fptr;
78 #endif
79 }
80
81 /*
82  * OpenGL 1.2 and 1.3 enumerants
83  */
84
85 #ifndef GL_VERSION_1_2
86 #define GL_CLAMP_TO_EDGE                                        0x812F
87 #define GL_TEXTURE_WRAP_R                                       0x8072
88 #define GL_BLEND_EQUATION                                       0x8009
89 #define GL_MIN                                                  0x8007
90 #define GL_MAX                                                  0x8008
91 #define GL_FUNC_ADD                                             0x8006
92 #define GL_FUNC_SUBTRACT                                        0x800A
93 #define GL_FUNC_REVERSE_SUBTRACT                                0x800B
94 #define GL_BLEND_COLOR                                          0x8005
95 #define GL_CONSTANT_COLOR                                       0x8001
96 #define GL_ONE_MINUS_CONSTANT_COLOR                             0x8002
97 #define GL_CONSTANT_ALPHA                                       0x8003
98 #define GL_ONE_MINUS_CONSTANT_ALPHA                             0x8004
99 #endif
100
101 typedef void (APIENTRY * glBlendEquationProc) (GLenum mode );
102 typedef void (APIENTRY * glBlendColorProc) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha );
103
104
105 /* OpenGL extension declarations */
106
107 /*
108  * glPointParameterf and glPointParameterfv
109  */
110 #ifndef GL_EXT_point_parameters
111 #define GL_EXT_point_parameters 1
112 #define GL_POINT_SIZE_MIN_EXT                                   0x8126
113 #define GL_DISTANCE_ATTENUATION_EXT                             0x8129
114 #endif
115
116 #ifndef GL_ARB_point_parameters
117 #define GL_ARB_point_parameters 1
118 #define GL_POINT_SIZE_MIN_ARB                                   0x8126
119 #define GL_DISTANCE_ATTENUATION_ARB                             0x8129
120 #endif
121
122 typedef void (APIENTRY * glPointParameterfProc)(GLenum pname, GLfloat param);
123 typedef void (APIENTRY * glPointParameterfvProc)(GLenum pname, const GLfloat *params);
124
125 /*
126  * glActiveTextureARB
127  */
128
129 #ifndef GL_ARB_multitexture
130 #define GL_ARB_multitexture 1
131 #define GL_TEXTURE0_ARB                                         0x84C0
132 #define GL_TEXTURE1_ARB                                         0x84C1
133 #define GL_TEXTURE2_ARB                                         0x84C2
134 #define GL_TEXTURE3_ARB                                         0x84C3
135 #define GL_TEXTURE4_ARB                                         0x84C4
136 #define GL_TEXTURE5_ARB                                         0x84C5
137 #define GL_TEXTURE6_ARB                                         0x84C6
138 #define GL_TEXTURE7_ARB                                         0x84C7
139 #define GL_TEXTURE8_ARB                                         0x84C8
140 #define GL_TEXTURE9_ARB                                         0x84C9
141 #define GL_TEXTURE10_ARB                                        0x84CA
142 #define GL_TEXTURE11_ARB                                        0x84CB
143 #define GL_TEXTURE12_ARB                                        0x84CC
144 #define GL_TEXTURE13_ARB                                        0x84CD
145 #define GL_TEXTURE14_ARB                                        0x84CE
146 #define GL_TEXTURE15_ARB                                        0x84CF
147 #define GL_TEXTURE16_ARB                                        0x84D0
148 #define GL_TEXTURE17_ARB                                        0x84D1
149 #define GL_TEXTURE18_ARB                                        0x84D2
150 #define GL_TEXTURE19_ARB                                        0x84D3
151 #define GL_TEXTURE20_ARB                                        0x84D4
152 #define GL_TEXTURE21_ARB                                        0x84D5
153 #define GL_TEXTURE22_ARB                                        0x84D6
154 #define GL_TEXTURE23_ARB                                        0x84D7
155 #define GL_TEXTURE24_ARB                                        0x84D8
156 #define GL_TEXTURE25_ARB                                        0x84D9
157 #define GL_TEXTURE26_ARB                                        0x84DA
158 #define GL_TEXTURE27_ARB                                        0x84DB
159 #define GL_TEXTURE28_ARB                                        0x84DC
160 #define GL_TEXTURE29_ARB                                        0x84DD
161 #define GL_TEXTURE30_ARB                                        0x84DE
162 #define GL_TEXTURE31_ARB                                        0x84DF
163 #define GL_ACTIVE_TEXTURE_ARB                                   0x84E0
164 #define GL_CLIENT_ACTIVE_TEXTURE_ARB                            0x84E1
165 #define GL_MAX_TEXTURE_UNITS_ARB                                0x84E2
166 #endif
167
168 typedef void (APIENTRY * glActiveTextureProc)(GLenum texture);
169 typedef void (APIENTRY * glClientActiveTextureProc)(GLenum texture);
170
171 /*
172  * GL_EXT_separate_specular_color
173  */
174
175 #ifndef GL_LIGHT_MODEL_COLOR_CONTROL
176 #define GL_LIGHT_MODEL_COLOR_CONTROL                            0x81F8
177 #define GL_SINGLE_COLOR                                         0x81F9
178 #define GL_SEPARATE_SPECULAR_COLOR                              0x81FA
179 #endif
180
181 /*
182  * GL_ARB_texture_cube_map
183  */
184
185 #ifndef GL_ARB_texture_cube_map
186 #define GL_ARB_texture_cube_map 1
187 #define GL_NORMAL_MAP_ARB                                       0x8511
188 #define GL_REFLECTION_MAP_ARB                                   0x8512
189 #define GL_TEXTURE_CUBE_MAP_ARB                                 0x8513
190 #define GL_TEXTURE_BINDING_CUBE_MAP_ARB                         0x8514
191 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB                      0x8515
192 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB                      0x8516
193 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB                      0x8517
194 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB                      0x8518
195 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB                      0x8519
196 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB                      0x851A
197 #define GL_PROXY_TEXTURE_CUBE_MAP_ARB                           0x851B
198 #define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB                        0x851C
199 #endif
200
201 /*
202  * GL_ARB_texture_env_combine
203  */
204
205 #ifndef GL_ARB_texture_env_combine
206 #define GL_ARB_texture_env_combine 1
207 #define GL_COMBINE_ARB                                          0x8570
208 #define GL_COMBINE_RGB_ARB                                      0x8571
209 #define GL_COMBINE_ALPHA_ARB                                    0x8572
210 #define GL_RGB_SCALE_ARB                                        0x8573
211 #define GL_ADD_SIGNED_ARB                                       0x8574
212 #define GL_INTERPOLATE_ARB                                      0x8575
213 #define GL_CONSTANT_ARB                                         0x8576
214 #define GL_PRIMARY_COLOR_ARB                                    0x8577
215 #define GL_PREVIOUS_ARB                                         0x8578
216 #define GL_SOURCE0_RGB_ARB                                      0x8580
217 #define GL_SOURCE1_RGB_ARB                                      0x8581
218 #define GL_SOURCE2_RGB_ARB                                      0x8582
219 #define GL_SOURCE0_ALPHA_ARB                                    0x8588
220 #define GL_SOURCE1_ALPHA_ARB                                    0x8589
221 #define GL_SOURCE2_ALPHA_ARB                                    0x858A
222 #define GL_OPERAND0_RGB_ARB                                     0x8590
223 #define GL_OPERAND1_RGB_ARB                                     0x8591
224 #define GL_OPERAND2_RGB_ARB                                     0x8592
225 #define GL_OPERAND0_ALPHA_ARB                                   0x8598
226 #define GL_OPERAND1_ALPHA_ARB                                   0x8599
227 #define GL_OPERAND2_ALPHA_ARB                                   0x859A
228 #endif
229
230 /*
231  * GL_ARB_texture_env_dot3
232  */
233
234 #ifndef GL_ARB_texture_env_dot3
235 #define GL_ARB_texture_env_dot3 1
236 #define GL_DOT3_RGB_ARB                                         0x86AE
237 #define GL_DOT3_RGBA_ARB                                        0x86AF
238 #endif
239
240 #if defined(__cplusplus)
241 }
242 #endif
243
244 #endif // !__SG_EXTENSIONS_HXX
245