3 * Copyright (c) 2001 César Blecua Udías All Rights Reserved.
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:
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
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
24 #ifndef __SG_EXTENSIONS_HXX
25 #define __SG_EXTENSIONS_HXX 1
27 #if defined(__CYGWIN__) && !defined(WIN32) /* && !defined(USING_X) */
31 #if defined(WIN32) /* MINGW and MSC predefine WIN32 */
39 #include <simgear/compiler.h>
44 #if defined(__cplusplus)
52 // static bool SGSearchExtensionsString(char *extString, char *extName);
53 bool SGIsOpenGLExtensionSupported(char *extName);
56 // don't use an inline function for symbol lookup, since it is too big
57 void* macosxGetGLProcAddress(const char *func);
59 #elif !defined( WIN32 )
61 void *SGGetGLProcAddress(const char *func);
65 inline void (*SGLookupFunction(const char *func))()
68 return (void (*)()) wglGetProcAddress(func);
70 #elif defined( __APPLE__ )
71 return (void (*)()) macosxGetGLProcAddress(func);
75 return (void (*)()) SGGetGLProcAddress(func);
80 * OpenGL 1.2 and 1.3 enumerants
83 #ifndef GL_VERSION_1_2
84 #define GL_CLAMP_TO_EDGE 0x812F
85 #define GL_TEXTURE_WRAP_R 0x8072
86 #define GL_BLEND_EQUATION 0x8009
89 #define GL_FUNC_ADD 0x8006
90 #define GL_FUNC_SUBTRACT 0x800A
91 #define GL_FUNC_REVERSE_SUBTRACT 0x800B
92 #define GL_BLEND_COLOR 0x8005
93 #define GL_CONSTANT_COLOR 0x8001
94 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
95 #define GL_CONSTANT_ALPHA 0x8003
96 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
99 typedef void (APIENTRY * glBlendEquationProc) (GLenum mode );
100 typedef void (APIENTRY * glBlendColorProc) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha );
103 /* OpenGL extension declarations */
106 * glPointParameterf and glPointParameterfv
108 #ifndef GL_EXT_point_parameters
109 #define GL_EXT_point_parameters 1
110 #define GL_POINT_SIZE_MIN_EXT 0x8126
111 #define GL_DISTANCE_ATTENUATION_EXT 0x8129
114 #ifndef GL_ARB_point_parameters
115 #define GL_ARB_point_parameters 1
116 #define GL_POINT_SIZE_MIN_ARB 0x8126
117 #define GL_DISTANCE_ATTENUATION_ARB 0x8129
120 typedef void (APIENTRY * glPointParameterfProc)(GLenum pname, GLfloat param);
121 typedef void (APIENTRY * glPointParameterfvProc)(GLenum pname, const GLfloat *params);
127 #ifndef GL_ARB_multitexture
128 #define GL_ARB_multitexture 1
129 #define GL_TEXTURE0_ARB 0x84C0
130 #define GL_TEXTURE1_ARB 0x84C1
131 #define GL_TEXTURE2_ARB 0x84C2
132 #define GL_TEXTURE3_ARB 0x84C3
133 #define GL_TEXTURE4_ARB 0x84C4
134 #define GL_TEXTURE5_ARB 0x84C5
135 #define GL_TEXTURE6_ARB 0x84C6
136 #define GL_TEXTURE7_ARB 0x84C7
137 #define GL_TEXTURE8_ARB 0x84C8
138 #define GL_TEXTURE9_ARB 0x84C9
139 #define GL_TEXTURE10_ARB 0x84CA
140 #define GL_TEXTURE11_ARB 0x84CB
141 #define GL_TEXTURE12_ARB 0x84CC
142 #define GL_TEXTURE13_ARB 0x84CD
143 #define GL_TEXTURE14_ARB 0x84CE
144 #define GL_TEXTURE15_ARB 0x84CF
145 #define GL_TEXTURE16_ARB 0x84D0
146 #define GL_TEXTURE17_ARB 0x84D1
147 #define GL_TEXTURE18_ARB 0x84D2
148 #define GL_TEXTURE19_ARB 0x84D3
149 #define GL_TEXTURE20_ARB 0x84D4
150 #define GL_TEXTURE21_ARB 0x84D5
151 #define GL_TEXTURE22_ARB 0x84D6
152 #define GL_TEXTURE23_ARB 0x84D7
153 #define GL_TEXTURE24_ARB 0x84D8
154 #define GL_TEXTURE25_ARB 0x84D9
155 #define GL_TEXTURE26_ARB 0x84DA
156 #define GL_TEXTURE27_ARB 0x84DB
157 #define GL_TEXTURE28_ARB 0x84DC
158 #define GL_TEXTURE29_ARB 0x84DD
159 #define GL_TEXTURE30_ARB 0x84DE
160 #define GL_TEXTURE31_ARB 0x84DF
161 #define GL_ACTIVE_TEXTURE_ARB 0x84E0
162 #define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
163 #define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
166 typedef void (APIENTRY * glActiveTextureProc)(GLenum texture);
167 typedef void (APIENTRY * glClientActiveTextureProc)(GLenum texture);
170 * GL_EXT_separate_specular_color
173 #ifndef GL_LIGHT_MODEL_COLOR_CONTROL
174 #define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
175 #define GL_SINGLE_COLOR 0x81F9
176 #define GL_SEPARATE_SPECULAR_COLOR 0x81FA
180 * GL_ARB_texture_cube_map
183 #ifndef GL_ARB_texture_cube_map
184 #define GL_ARB_texture_cube_map 1
185 #define GL_NORMAL_MAP_ARB 0x8511
186 #define GL_REFLECTION_MAP_ARB 0x8512
187 #define GL_TEXTURE_CUBE_MAP_ARB 0x8513
188 #define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514
189 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515
190 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516
191 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517
192 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518
193 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519
194 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A
195 #define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B
196 #define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C
200 * GL_ARB_texture_env_combine
203 #ifndef GL_ARB_texture_env_combine
204 #define GL_ARB_texture_env_combine 1
205 #define GL_COMBINE_ARB 0x8570
206 #define GL_COMBINE_RGB_ARB 0x8571
207 #define GL_COMBINE_ALPHA_ARB 0x8572
208 #define GL_RGB_SCALE_ARB 0x8573
209 #define GL_ADD_SIGNED_ARB 0x8574
210 #define GL_INTERPOLATE_ARB 0x8575
211 #define GL_CONSTANT_ARB 0x8576
212 #define GL_PRIMARY_COLOR_ARB 0x8577
213 #define GL_PREVIOUS_ARB 0x8578
214 #define GL_SOURCE0_RGB_ARB 0x8580
215 #define GL_SOURCE1_RGB_ARB 0x8581
216 #define GL_SOURCE2_RGB_ARB 0x8582
217 #define GL_SOURCE0_ALPHA_ARB 0x8588
218 #define GL_SOURCE1_ALPHA_ARB 0x8589
219 #define GL_SOURCE2_ALPHA_ARB 0x858A
220 #define GL_OPERAND0_RGB_ARB 0x8590
221 #define GL_OPERAND1_RGB_ARB 0x8591
222 #define GL_OPERAND2_RGB_ARB 0x8592
223 #define GL_OPERAND0_ALPHA_ARB 0x8598
224 #define GL_OPERAND1_ALPHA_ARB 0x8599
225 #define GL_OPERAND2_ALPHA_ARB 0x859A
229 * GL_ARB_texture_env_dot3
232 #ifndef GL_ARB_texture_env_dot3
233 #define GL_ARB_texture_env_dot3 1
234 #define GL_DOT3_RGB_ARB 0x86AE
235 #define GL_DOT3_RGBA_ARB 0x86AF
241 #ifndef GL_ARB_depth_texture
242 #define GL_ARB_depth_texture 1
243 #define GL_DEPTH_COMPONENT16_ARB 0x81A5
244 #define GL_DEPTH_COMPONENT24_ARB 0x81A6
245 #define GL_DEPTH_COMPONENT32_ARB 0x81A7
246 #define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A
247 #define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
253 #ifndef GL_ARB_multisample
254 #define GL_ARB_multisample 1
255 #define GL_MULTISAMPLE_ARB 0x809D
256 #define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E
257 #define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F
258 #define GL_SAMPLE_COVERAGE_ARB 0x80A0
259 #define GL_SAMPLE_BUFFERS_ARB 0x80A8
260 #define GL_SAMPLES_ARB 0x80A9
261 #define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA
262 #define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB
263 #define GL_MULTISAMPLE_BIT_ARB 0x20000000
268 /* WGL spcific OpenGL extenstions */
274 #ifndef GL_ARB_pbuffer
275 #define GL_ARB_pbuffer 1
276 #define GL_DRAW_TO_PBUFFER_ARB 0x202D
277 #define GL_MAX_PBUFFER_PIXELS_ARB 0x202E
278 #define GL_MAX_PBUFFER_WIDTH_ARB 0x202F
279 #define GL_MAX_PBUFFER_HEIGHT_ARB 0x2030
280 #define GL_PBUFFER_LARGEST_ARB 0x2033
281 #define GL_PBUFFER_WIDTH_ARB 0x2034
282 #define GL_PBUFFER_HEIGHT_ARB 0x2035
283 #define GL_PBUFFER_LOST_ARB 0x2036
284 DECLARE_HANDLE(HPBUFFERARB);
285 typedef HPBUFFERARB (APIENTRY * wglCreatePbufferARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
286 typedef HDC (APIENTRY * wglGetPbufferDCARBPROC) (HPBUFFERARB hPbuffer);
287 typedef int (APIENTRY * wglReleasePbufferDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
288 typedef BOOL (APIENTRY * wglDestroyPbufferARBPROC) (HPBUFFERARB hPbuffer);
289 typedef BOOL (APIENTRY * wglQueryPbufferARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
296 #ifndef GL_ARB_pixel_format
297 #define GL_ARB_pixel_format 1
298 #define GL_NUMBER_PIXEL_FORMATS_ARB 0x2000
299 #define GL_DRAW_TO_WINDOW_ARB 0x2001
300 #define GL_DRAW_TO_BITMAP_ARB 0x2002
301 #define GL_ACCELERATION_ARB 0x2003
302 #define GL_NEED_PALETTE_ARB 0x2004
303 #define GL_NEED_SYSTEM_PALETTE_ARB 0x2005
304 #define GL_SWAP_LAYER_BUFFERS_ARB 0x2006
305 #define GL_SWAP_METHOD_ARB 0x2007
306 #define GL_NUMBER_OVERLAYS_ARB 0x2008
307 #define GL_NUMBER_UNDERLAYS_ARB 0x2009
308 #define GL_TRANSPARENT_ARB 0x200A
309 #define GL_SHARE_DEPTH_ARB 0x200C
310 #define GL_SHARE_STENCIL_ARB 0x200D
311 #define GL_SHARE_ACCUM_ARB 0x200E
312 #define GL_SUPPORT_GDI_ARB 0x200F
313 #define GL_SUPPORT_OPENGL_ARB 0x2010
314 #define GL_DOUBLE_BUFFER_ARB 0x2011
315 #define GL_STEREO_ARB 0x2012
316 #define GL_PIXEL_TYPE_ARB 0x2013
317 #define GL_COLOR_BITS_ARB 0x2014
318 #define GL_RED_BITS_ARB 0x2015
319 #define GL_RED_SHIFT_ARB 0x2016
320 #define GL_GREEN_BITS_ARB 0x2017
321 #define GL_GREEN_SHIFT_ARB 0x2018
322 #define GL_BLUE_BITS_ARB 0x2019
323 #define GL_BLUE_SHIFT_ARB 0x201A
324 #define GL_ALPHA_BITS_ARB 0x201B
325 #define GL_ALPHA_SHIFT_ARB 0x201C
326 #define GL_ACCUM_BITS_ARB 0x201D
327 #define GL_ACCUM_RED_BITS_ARB 0x201E
328 #define GL_ACCUM_GREEN_BITS_ARB 0x201F
329 #define GL_ACCUM_BLUE_BITS_ARB 0x2020
330 #define GL_ACCUM_ALPHA_BITS_ARB 0x2021
331 #define GL_DEPTH_BITS_ARB 0x2022
332 #define GL_STENCIL_BITS_ARB 0x2023
333 #define GL_AUX_BUFFERS_ARB 0x2024
334 #define GL_NO_ACCELERATION_ARB 0x2025
335 #define GL_GENERIC_ACCELERATION_ARB 0x2026
336 #define GL_FULL_ACCELERATION_ARB 0x2027
337 #define GL_SWAP_EXCHANGE_ARB 0x2028
338 #define GL_SWAP_COPY_ARB 0x2029
339 #define GL_SWAP_UNDEFINED_ARB 0x202A
340 #define GL_TYPE_RGBA_ARB 0x202B
341 #define GL_TYPE_COLORINDEX_ARB 0x202C
342 #define GL_TRANSPARENT_RED_VALUE_ARB 0x2037
343 #define GL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
344 #define GL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
345 #define GL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
346 #define GL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
347 typedef BOOL (APIENTRY * wglGetPixelFormatAttribivARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
348 typedef BOOL (APIENTRY * wglGetPixelFormatAttribfvARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
349 typedef BOOL (APIENTRY * wglChoosePixelFormatARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
355 #ifndef GL_ARB_render_texture
356 #define GL_ARB_render_texture 1
358 #define GL_BIND_TO_TEXTURE_RGB_ARB 0x2070
359 #define GL_BIND_TO_TEXTURE_RGBA_ARB 0x2071
360 #define GL_TEXTURE_FORMAT_ARB 0x2072
361 #define GL_TEXTURE_TARGET_ARB 0x2073
362 #define GL_MIPMAP_TEXTURE_ARB 0x2074
363 #define GL_TEXTURE_RGB_ARB 0x2075
364 #define GL_TEXTURE_RGBA_ARB 0x2076
365 #define GL_NO_TEXTURE_ARB 0x2077
366 #define GL_TEXTURE_CUBE_MAP_ARB 0x2078
367 #define GL_TEXTURE_1D_ARB 0x2079
368 #define GL_TEXTURE_2D_ARB 0x207A
369 #define GL_NO_TEXTURE_ARB 0x2077
370 #define GL_MIPMAP_LEVEL_ARB 0x207B
371 #define GL_CUBE_MAP_FACE_ARB 0x207C
372 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
373 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
374 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
375 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
376 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
377 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
378 #define GL_FRONT_LEFT_ARB 0x2083
379 #define GL_FRONT_RIGHT_ARB 0x2084
380 #define GL_BACK_LEFT_ARB 0x2085
381 #define GL_BACK_RIGHT_ARB 0x2086
382 #define GL_AUX0_ARB 0x2087
383 #define GL_AUX1_ARB 0x2088
384 #define GL_AUX2_ARB 0x2089
385 #define GL_AUX3_ARB 0x208A
386 #define GL_AUX4_ARB 0x208B
387 #define GL_AUX5_ARB 0x208C
388 #define GL_AUX6_ARB 0x208D
389 #define GL_AUX7_ARB 0x208E
390 #define GL_AUX8_ARB 0x208F
391 #define GL_AUX9_ARB 0x2090
392 typedef BOOL (APIENTRY * wglBindTexImageARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
393 typedef BOOL (APIENTRY * wglReleaseTexImageARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
394 typedef BOOL (APIENTRY * wglSetPbufferAttribARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
400 /* NVIDIA specific extension */
403 * NV_texture_rectangle
406 #ifndef GL_NV_texture_rectangle
407 #define GL_NV_texture_rectangle 1
408 #define GL_TEXTURE_RECTANGLE_NV 0x84F5
409 #define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6
410 #define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7
411 #define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8
415 * NV_render_depth_texture
418 #ifndef GL_NV_render_depth_texture
419 #define GL_NV_render_depth_texture 1
420 #define GL_NO_TEXTURE_ARBxi 0x2077
421 #define GL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3
422 #define GL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4
423 #define GL_DEPTH_TEXTURE_FORMAT_NV 0x20A5
424 #define GL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6
425 #define GL_DEPTH_COMPONENT_NV 0x20A7
431 #ifndef GL_NV_float_buffer
432 #define GL_NV_float_buffer 1
433 #define GL_FLOAT_R_NV 0x8880
434 #define GL_FLOAT_RG_NV 0x8881
435 #define GL_FLOAT_RGB_NV 0x8882
436 #define GL_FLOAT_RGBA_NV 0x8883
437 #define GL_FLOAT_R16_NV 0x8884
438 #define GL_FLOAT_R32_NV 0x8885
439 #define GL_FLOAT_RG16_NV 0x8886
440 #define GL_FLOAT_RG32_NV 0x8887
441 #define GL_FLOAT_RGB16_NV 0x8888
442 #define GL_FLOAT_RGB32_NV 0x8889
443 #define GL_FLOAT_RGBA16_NV 0x888A
444 #define GL_FLOAT_RGBA32_NV 0x888B
445 #define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C
446 #define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D
447 #define GL_FLOAT_RGBA_MODE_NV 0x888E
448 #define GL_FLOAT_COMPONENTS_NV 0x20B0
449 #define GL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1
450 #define GL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2
451 #define GL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3
452 #define GL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4
453 #define GL_TEXTURE_FLOAT_R_NV 0x20B5
454 #define GL_TEXTURE_FLOAT_RG_NV 0x20B6
455 #define GL_TEXTURE_FLOAT_RGB_NV 0x20B7
456 #define GL_TEXTURE_FLOAT_RGBA_NV 0x20B8
460 /* ATI specific extension */
463 * ATI_pixel_format_float
465 #ifndef GL_ATI_pixel_format_float
466 #define GL_ATI_pixel_format_float 1
467 #define GL_TYPE_RGBA_FLOAT_ATI 0x21A0
468 #define GL_RGBA_FLOAT_MODE_ATI 0x8820
469 #define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835
475 #ifndef GL_ATI_texture_float
476 #define GL_ATI_texture_float 1
477 #define GL_RGBA_FLOAT32_ATI 0x8814
478 #define GL_RGB_FLOAT32_ATI 0x8815
479 #define GL_ALPHA_FLOAT32_ATI 0x8816
480 #define GL_INTENSITY_FLOAT32_ATI 0x8817
481 #define GL_LUMINANCE_FLOAT32_ATI 0x8818
482 #define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819
483 #define GL_RGBA_FLOAT16_ATI 0x881A
484 #define GL_RGB_FLOAT16_ATI 0x881B
485 #define GL_ALPHA_FLOAT16_ATI 0x881C
486 #define GL_INTENSITY_FLOAT16_ATI 0x881D
487 #define GL_LUMINANCE_FLOAT16_ATI 0x881E
488 #define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F
492 #if defined(__cplusplus)
496 #endif // !__SG_EXTENSIONS_HXX