080fa98dfc6b4d3328fb494152fb20a308f0ec87
[mesa.git] / src / mesa / main / extensions.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.6
4 *
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26
27 #include "glheader.h"
28 #include "imports.h"
29 #include "context.h"
30 #include "extensions.h"
31 #include "mtypes.h"
32
33
34 #define F(x) offsetof(struct gl_extensions, x)
35 #define ON GL_TRUE
36 #define OFF GL_FALSE
37
38
39 /*
40 * Note: The GL_MESAX_* extensions are placeholders for future ARB extensions.
41 */
42 static const struct {
43 GLboolean enabled;
44 const char *name;
45 int flag_offset;
46 } default_extensions[] = {
47 { OFF, "GL_ARB_blend_func_extended", F(ARB_blend_func_extended) },
48 { OFF, "GL_ARB_copy_buffer", F(ARB_copy_buffer) },
49 { OFF, "GL_ARB_depth_buffer_float", F(ARB_depth_buffer_float) },
50 { OFF, "GL_ARB_depth_clamp", F(ARB_depth_clamp) },
51 { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) },
52 { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) },
53 { OFF, "GL_ARB_draw_elements_base_vertex", F(ARB_draw_elements_base_vertex) },
54 { OFF, "GL_ARB_draw_instanced", F(ARB_draw_instanced) },
55 { OFF, "GL_ARB_fragment_coord_conventions", F(ARB_fragment_coord_conventions) },
56 { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) },
57 { OFF, "GL_ARB_fragment_program_shadow", F(ARB_fragment_program_shadow) },
58 { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) },
59 { OFF, "GL_ARB_framebuffer_object", F(ARB_framebuffer_object) },
60 { OFF, "GL_ARB_explicit_attrib_location", F(ARB_explicit_attrib_location) },
61 /* TODO: reenable this when the new GLSL compiler actually supports them */
62 /* { OFF, "GL_ARB_geometry_shader4", F(ARB_geometry_shader4) }, */
63 { OFF, "GL_ARB_half_float_pixel", F(ARB_half_float_pixel) },
64 { OFF, "GL_ARB_half_float_vertex", F(ARB_half_float_vertex) },
65 { OFF, "GL_ARB_imaging", F(ARB_imaging) },
66 { OFF, "GL_ARB_instanced_arrays", F(ARB_instanced_arrays) },
67 { OFF, "GL_ARB_map_buffer_range", F(ARB_map_buffer_range) },
68 { ON, "GL_ARB_multisample", F(ARB_multisample) },
69 { OFF, "GL_ARB_multitexture", F(ARB_multitexture) },
70 { OFF, "GL_ARB_occlusion_query", F(ARB_occlusion_query) },
71 { OFF, "GL_ARB_occlusion_query2", F(ARB_occlusion_query2) },
72 { OFF, "GL_ARB_pixel_buffer_object", F(EXT_pixel_buffer_object) },
73 { OFF, "GL_ARB_point_parameters", F(EXT_point_parameters) },
74 { OFF, "GL_ARB_point_sprite", F(ARB_point_sprite) },
75 { OFF, "GL_ARB_provoking_vertex", F(EXT_provoking_vertex) },
76 { OFF, "GL_ARB_sampler_objects", F(ARB_sampler_objects) },
77 { OFF, "GL_ARB_seamless_cube_map", F(ARB_seamless_cube_map) },
78 { OFF, "GL_ARB_shader_objects", F(ARB_shader_objects) },
79 { OFF, "GL_ARB_shading_language_100", F(ARB_shading_language_100) },
80 { OFF, "GL_ARB_shadow", F(ARB_shadow) },
81 { OFF, "GL_ARB_shadow_ambient", F(ARB_shadow_ambient) },
82 { OFF, "GL_ARB_sync", F(ARB_sync) },
83 { OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) },
84 { OFF, "GL_ARB_texture_buffer_object", F(ARB_texture_buffer_object) },
85 { ON, "GL_ARB_texture_compression", F(ARB_texture_compression) },
86 { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) },
87 { OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) },
88 { OFF, "GL_ARB_texture_env_combine", F(ARB_texture_env_combine) },
89 { OFF, "GL_ARB_texture_env_crossbar", F(ARB_texture_env_crossbar) },
90 { OFF, "GL_ARB_texture_env_dot3", F(ARB_texture_env_dot3) },
91 { OFF, "GL_MESAX_texture_float", F(ARB_texture_float) },
92 { OFF, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
93 { OFF, "GL_ARB_texture_multisample", F(ARB_texture_multisample) },
94 { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)},
95 { OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) },
96 { OFF, "GL_ARB_texture_rg", F(ARB_texture_rg) },
97 { OFF, "GL_ARB_texture_rgb10_a2ui", F(ARB_texture_rgb10_a2ui) },
98 { OFF, "GL_ARB_texture_swizzle", F(EXT_texture_swizzle) },
99 { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) },
100 { OFF, "GL_ARB_transform_feedback2", F(ARB_transform_feedback2) },
101 { OFF, "GL_ARB_uniform_buffer_object", F(ARB_uniform_buffer_object) },
102 { OFF, "GL_ARB_vertex_array_bgra", F(EXT_vertex_array_bgra) },
103 { OFF, "GL_ARB_vertex_array_object", F(ARB_vertex_array_object) },
104 { ON, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) },
105 { OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) },
106 { OFF, "GL_ARB_vertex_shader", F(ARB_vertex_shader) },
107 { OFF, "GL_ARB_vertex_type_2_10_10_10_rev", F(ARB_vertex_type_2_10_10_10_rev) },
108 { ON, "GL_ARB_window_pos", F(ARB_window_pos) },
109 { ON, "GL_EXT_abgr", F(EXT_abgr) },
110 { ON, "GL_EXT_bgra", F(EXT_bgra) },
111 { OFF, "GL_EXT_blend_color", F(EXT_blend_color) },
112 { OFF, "GL_EXT_blend_equation_separate", F(EXT_blend_equation_separate) },
113 { OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) },
114 { OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) },
115 { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) },
116 { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) },
117 { OFF, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) },
118 { OFF, "GL_EXT_cull_vertex", F(EXT_cull_vertex) },
119 { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) },
120 { OFF, "GL_EXT_convolution", F(EXT_convolution) },
121 { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) },
122 { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) },
123 { OFF, "GL_EXT_draw_buffers2", F(EXT_draw_buffers2) },
124 { OFF, "GL_EXT_draw_instanced", F(ARB_draw_instanced) },
125 { ON, "GL_EXT_draw_range_elements", F(EXT_draw_range_elements) },
126 { OFF, "GL_EXT_framebuffer_blit", F(EXT_framebuffer_blit) },
127 { OFF, "GL_EXT_framebuffer_multisample", F(EXT_framebuffer_multisample) },
128 { OFF, "GL_EXT_framebuffer_object", F(EXT_framebuffer_object) },
129 { OFF, "GL_EXT_framebuffer_sRGB", F(EXT_framebuffer_sRGB) },
130 { OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) },
131 { OFF, "GL_EXT_gpu_program_parameters", F(EXT_gpu_program_parameters) },
132 { OFF, "GL_EXT_histogram", F(EXT_histogram) },
133 { ON, "GL_EXT_multi_draw_arrays", F(EXT_multi_draw_arrays) },
134 { OFF, "GL_EXT_packed_depth_stencil", F(EXT_packed_depth_stencil) },
135 { OFF, "GL_EXT_packed_float", F(EXT_packed_float) },
136 { ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) },
137 { OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) },
138 { OFF, "GL_EXT_pixel_buffer_object", F(EXT_pixel_buffer_object) },
139 { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) },
140 { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) },
141 { OFF, "GL_EXT_provoking_vertex", F(EXT_provoking_vertex) },
142 { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) },
143 { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) },
144 { ON, "GL_EXT_separate_specular_color", F(EXT_separate_specular_color) },
145 { OFF, "GL_EXT_shadow_funcs", F(EXT_shadow_funcs) },
146 { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) },
147 { OFF, "GL_EXT_stencil_two_side", F(EXT_stencil_two_side) },
148 { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) },
149 { ON, "GL_EXT_subtexture", F(EXT_subtexture) },
150 { ON, "GL_EXT_texture", F(EXT_texture) },
151 { ON, "GL_EXT_texture3D", F(EXT_texture3D) },
152 { OFF, "GL_EXT_texture_array", F(EXT_texture_array) },
153 { OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) },
154 { OFF, "GL_EXT_texture_compression_rgtc", F(EXT_texture_compression_rgtc) },
155 { OFF, "GL_EXT_texture_cube_map", F(ARB_texture_cube_map) },
156 { ON, "GL_EXT_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
157 { OFF, "GL_EXT_texture_env_add", F(EXT_texture_env_add) },
158 { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) },
159 { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) },
160 { OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) },
161 { OFF, "GL_EXT_texture_integer", F(EXT_texture_integer) },
162 { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) },
163 { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) },
164 { ON, "GL_EXT_texture_object", F(EXT_texture_object) },
165 { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) },
166 { OFF, "GL_EXT_texture_shared_exponent", F(EXT_texture_shared_exponent) },
167 { OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) },
168 { OFF, "GL_EXT_texture_swizzle", F(EXT_texture_swizzle) },
169 { OFF, "GL_EXT_timer_query", F(EXT_timer_query) },
170 { OFF, "GL_EXT_transform_feedback", F(EXT_transform_feedback) },
171 { ON, "GL_EXT_vertex_array", F(EXT_vertex_array) },
172 { OFF, "GL_EXT_vertex_array_bgra", F(EXT_vertex_array_bgra) },
173 { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) },
174 { OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) },
175 { OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) },
176 { ON, "GL_APPLE_packed_pixels", F(APPLE_packed_pixels) },
177 { OFF, "GL_APPLE_vertex_array_object", F(APPLE_vertex_array_object) },
178 { OFF, "GL_APPLE_object_purgeable", F(APPLE_object_purgeable) },
179 { OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate) },
180 { OFF, "GL_ATI_envmap_bumpmap", F(ATI_envmap_bumpmap) },
181 { OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)},
182 { OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)},
183 { OFF, "GL_ATI_fragment_shader", F(ATI_fragment_shader)},
184 { OFF, "GL_ATI_separate_stencil", F(ATI_separate_stencil)},
185 { ON, "GL_IBM_multimode_draw_arrays", F(IBM_multimode_draw_arrays) },
186 { ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) },
187 { OFF, "GL_IBM_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
188 { OFF, "GL_INGR_blend_func_separate", F(EXT_blend_func_separate) },
189 { OFF, "GL_MESA_pack_invert", F(MESA_pack_invert) },
190 { OFF, "GL_MESA_packed_depth_stencil", F(MESA_packed_depth_stencil) },
191 { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) },
192 { OFF, "GL_MESA_texture_array", F(MESA_texture_array) },
193 { OFF, "GL_MESA_texture_signed_rgba", F(MESA_texture_signed_rgba) },
194 { OFF, "GL_MESA_ycbcr_texture", F(MESA_ycbcr_texture) },
195 { ON, "GL_MESA_window_pos", F(ARB_window_pos) },
196 { OFF, "GL_NV_blend_square", F(NV_blend_square) },
197 { OFF, "GL_NV_conditional_render", F(NV_conditional_render) },
198 { OFF, "GL_NV_depth_clamp", F(ARB_depth_clamp) },
199 { OFF, "GL_NV_fragment_program", F(NV_fragment_program) },
200 { OFF, "GL_NV_fragment_program_option", F(NV_fragment_program_option) },
201 { ON, "GL_NV_light_max_exponent", F(NV_light_max_exponent) },
202 { OFF, "GL_NV_packed_depth_stencil", F(EXT_packed_depth_stencil) },
203 { OFF, "GL_NV_point_sprite", F(NV_point_sprite) },
204 { OFF, "GL_NV_primitive_restart", F(NV_primitive_restart) },
205 { ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) },
206 { OFF, "GL_NV_texture_env_combine4", F(NV_texture_env_combine4) },
207 { OFF, "GL_NV_texture_rectangle", F(NV_texture_rectangle) },
208 { OFF, "GL_NV_vertex_program", F(NV_vertex_program) },
209 { OFF, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1) },
210 { ON, "GL_OES_read_format", F(OES_read_format) },
211 { OFF, "GL_SGI_color_matrix", F(SGI_color_matrix) },
212 { OFF, "GL_SGI_color_table", F(SGI_color_table) },
213 { OFF, "GL_SGI_texture_color_table", F(SGI_texture_color_table) },
214 { OFF, "GL_SGIS_generate_mipmap", F(SGIS_generate_mipmap) },
215 { OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) },
216 { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
217 { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) },
218 { ON, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) },
219 { OFF, "GL_S3_s3tc", F(S3_s3tc) },
220 #if FEATURE_OES_EGL_image
221 { OFF, "GL_OES_EGL_image", F(OES_EGL_image) },
222 #endif
223 #if FEATURE_OES_draw_texture
224 { OFF, "GL_OES_draw_texture", F(OES_draw_texture) },
225 #endif /* FEATURE_OES_draw_texture */
226 };
227
228
229
230 /**
231 * Enable all extensions suitable for a software-only renderer.
232 * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc.
233 */
234 void
235 _mesa_enable_sw_extensions(GLcontext *ctx)
236 {
237 ctx->Extensions.ARB_copy_buffer = GL_TRUE;
238 ctx->Extensions.ARB_depth_clamp = GL_TRUE;
239 ctx->Extensions.ARB_depth_texture = GL_TRUE;
240 /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
241 ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE;
242 ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE;
243 #if FEATURE_ARB_fragment_program
244 ctx->Extensions.ARB_fragment_program = GL_TRUE;
245 ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE;
246 #endif
247 #if FEATURE_ARB_fragment_shader
248 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
249 #endif
250 #if FEATURE_ARB_framebuffer_object
251 ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
252 #endif
253 #if FEATURE_ARB_geometry_shader4
254 ctx->Extensions.ARB_geometry_shader4 = GL_TRUE;
255 #endif
256 ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
257 ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
258 ctx->Extensions.ARB_imaging = GL_TRUE;
259 ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
260 ctx->Extensions.ARB_multitexture = GL_TRUE;
261 #if FEATURE_queryobj
262 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
263 #endif
264 ctx->Extensions.ARB_point_sprite = GL_TRUE;
265 #if FEATURE_ARB_shader_objects
266 ctx->Extensions.ARB_shader_objects = GL_TRUE;
267 #endif
268 #if FEATURE_ARB_shading_language_100
269 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
270 #endif
271 ctx->Extensions.ARB_shadow = GL_TRUE;
272 ctx->Extensions.ARB_shadow_ambient = GL_TRUE;
273 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
274 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
275 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
276 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
277 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
278 /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/
279 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
280 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
281 ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
282 #if FEATURE_ARB_vertex_program
283 ctx->Extensions.ARB_vertex_program = GL_TRUE;
284 #endif
285 #if FEATURE_ARB_vertex_shader
286 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
287 #endif
288 #if FEATURE_ARB_vertex_buffer_object
289 /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
290 #endif
291 #if FEATURE_ARB_sync
292 ctx->Extensions.ARB_sync = GL_TRUE;
293 #endif
294 ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
295 #if FEATURE_APPLE_object_purgeable
296 ctx->Extensions.APPLE_object_purgeable = GL_TRUE;
297 #endif
298 ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE;
299 #if FEATURE_ATI_fragment_shader
300 ctx->Extensions.ATI_fragment_shader = GL_TRUE;
301 #endif
302 ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
303 ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
304 ctx->Extensions.ATI_separate_stencil = GL_TRUE;
305 ctx->Extensions.EXT_blend_color = GL_TRUE;
306 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
307 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
308 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
309 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
310 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
311 ctx->Extensions.EXT_convolution = GL_TRUE;
312 ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
313 ctx->Extensions.EXT_draw_buffers2 = GL_TRUE;
314 ctx->Extensions.EXT_fog_coord = GL_TRUE;
315 #if FEATURE_EXT_framebuffer_object
316 ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
317 #endif
318 #if FEATURE_EXT_framebuffer_blit
319 ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
320 #endif
321 #if FEATURE_ARB_framebuffer_object
322 ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE;
323 #endif
324 ctx->Extensions.EXT_histogram = GL_TRUE;
325 /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
326 ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
327 ctx->Extensions.EXT_paletted_texture = GL_TRUE;
328 #if FEATURE_EXT_pixel_buffer_object
329 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
330 #endif
331 ctx->Extensions.EXT_point_parameters = GL_TRUE;
332 ctx->Extensions.EXT_provoking_vertex = GL_TRUE;
333 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
334 ctx->Extensions.EXT_secondary_color = GL_TRUE;
335 ctx->Extensions.EXT_shared_texture_palette = GL_TRUE;
336 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
337 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
338 ctx->Extensions.EXT_texture_array = GL_TRUE;
339 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
340 ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
341 ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
342 ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
343 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
344 #if FEATURE_EXT_texture_sRGB
345 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
346 #endif
347 ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
348 #if FEATURE_EXT_transform_feedback
349 /*ctx->Extensions.EXT_transform_feedback = GL_TRUE;*/
350 #endif
351 ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
352 /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/
353 ctx->Extensions.MESA_pack_invert = GL_TRUE;
354 ctx->Extensions.MESA_resize_buffers = GL_TRUE;
355 ctx->Extensions.MESA_texture_array = GL_TRUE;
356 ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
357 ctx->Extensions.NV_blend_square = GL_TRUE;
358 ctx->Extensions.NV_conditional_render = GL_TRUE;
359 /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/
360 ctx->Extensions.NV_point_sprite = GL_TRUE;
361 ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
362 ctx->Extensions.NV_texture_rectangle = GL_TRUE;
363 /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/
364 #if FEATURE_NV_vertex_program
365 ctx->Extensions.NV_vertex_program = GL_TRUE;
366 ctx->Extensions.NV_vertex_program1_1 = GL_TRUE;
367 #endif
368 #if FEATURE_NV_fragment_program
369 ctx->Extensions.NV_fragment_program = GL_TRUE;
370 #endif
371 #if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program
372 ctx->Extensions.NV_fragment_program_option = GL_TRUE;
373 #endif
374 ctx->Extensions.SGI_color_matrix = GL_TRUE;
375 ctx->Extensions.SGI_color_table = GL_TRUE;
376 ctx->Extensions.SGI_texture_color_table = GL_TRUE;
377 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
378 ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE;
379 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
380 ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE;
381 #endif
382 #if FEATURE_texture_fxt1
383 _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
384 #endif
385 #if FEATURE_texture_s3tc
386 if (ctx->Mesa_DXTn) {
387 _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
388 _mesa_enable_extension(ctx, "GL_S3_s3tc");
389 }
390 #endif
391 }
392
393
394 /**
395 * Enable GL_ARB_imaging and all the EXT extensions that are subsets of it.
396 */
397 void
398 _mesa_enable_imaging_extensions(GLcontext *ctx)
399 {
400 ctx->Extensions.ARB_imaging = GL_TRUE;
401 ctx->Extensions.EXT_blend_color = GL_TRUE;
402 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
403 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
404 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
405 ctx->Extensions.EXT_convolution = GL_TRUE;
406 ctx->Extensions.EXT_histogram = GL_TRUE;
407 ctx->Extensions.SGI_color_matrix = GL_TRUE;
408 ctx->Extensions.SGI_color_table = GL_TRUE;
409 }
410
411
412
413 /**
414 * Enable all OpenGL 1.3 features and extensions.
415 * A convenience function to be called by drivers.
416 */
417 void
418 _mesa_enable_1_3_extensions(GLcontext *ctx)
419 {
420 /*ctx->Extensions.ARB_multisample = GL_TRUE;*/
421 ctx->Extensions.ARB_multitexture = GL_TRUE;
422 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
423 /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/
424 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
425 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
426 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
427 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
428 /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/
429 }
430
431
432
433 /**
434 * Enable all OpenGL 1.4 features and extensions.
435 * A convenience function to be called by drivers.
436 */
437 void
438 _mesa_enable_1_4_extensions(GLcontext *ctx)
439 {
440 ctx->Extensions.ARB_depth_texture = GL_TRUE;
441 ctx->Extensions.ARB_shadow = GL_TRUE;
442 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
443 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
444 ctx->Extensions.ARB_window_pos = GL_TRUE;
445 ctx->Extensions.EXT_blend_color = GL_TRUE;
446 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
447 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
448 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
449 ctx->Extensions.EXT_fog_coord = GL_TRUE;
450 /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
451 ctx->Extensions.EXT_point_parameters = GL_TRUE;
452 ctx->Extensions.EXT_secondary_color = GL_TRUE;
453 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
454 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
455 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
456 }
457
458
459 /**
460 * Enable all OpenGL 1.5 features and extensions.
461 * A convenience function to be called by drivers.
462 */
463 void
464 _mesa_enable_1_5_extensions(GLcontext *ctx)
465 {
466 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
467 /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
468 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
469 }
470
471
472 /**
473 * Enable all OpenGL 2.0 features and extensions.
474 * A convenience function to be called by drivers.
475 */
476 void
477 _mesa_enable_2_0_extensions(GLcontext *ctx)
478 {
479 /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
480 #if FEATURE_ARB_fragment_shader
481 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
482 #endif
483 ctx->Extensions.ARB_point_sprite = GL_TRUE;
484 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
485 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
486 #if FEATURE_ARB_shader_objects
487 ctx->Extensions.ARB_shader_objects = GL_TRUE;
488 #endif
489 #if FEATURE_ARB_shading_language_100
490 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
491 #endif
492 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
493 #if FEATURE_ARB_vertex_shader
494 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
495 #endif
496 }
497
498
499 /**
500 * Enable all OpenGL 2.1 features and extensions.
501 * A convenience function to be called by drivers.
502 */
503 void
504 _mesa_enable_2_1_extensions(GLcontext *ctx)
505 {
506 #if FEATURE_EXT_pixel_buffer_object
507 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
508 #endif
509 #if FEATURE_EXT_texture_sRGB
510 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
511 #endif
512 }
513
514
515 /**
516 * Either enable or disable the named extension.
517 * \return GL_TRUE for success, GL_FALSE if invalid extension name
518 */
519 static GLboolean
520 set_extension( GLcontext *ctx, const char *name, GLboolean state )
521 {
522 GLboolean *base = (GLboolean *) &ctx->Extensions;
523 GLuint i;
524
525 if (ctx->Extensions.String) {
526 /* The string was already queried - can't change it now! */
527 _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name);
528 return GL_FALSE;
529 }
530
531 for (i = 0 ; i < Elements(default_extensions) ; i++) {
532 if (strcmp(default_extensions[i].name, name) == 0) {
533 if (default_extensions[i].flag_offset) {
534 GLboolean *enabled = base + default_extensions[i].flag_offset;
535 *enabled = state;
536 }
537 return GL_TRUE;
538 }
539 }
540 return GL_FALSE;
541 }
542
543
544 /**
545 * Enable the named extension.
546 * Typically called by drivers.
547 */
548 void
549 _mesa_enable_extension( GLcontext *ctx, const char *name )
550 {
551 if (!set_extension(ctx, name, GL_TRUE))
552 _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
553 }
554
555
556 /**
557 * Disable the named extension.
558 * XXX is this really needed???
559 */
560 void
561 _mesa_disable_extension( GLcontext *ctx, const char *name )
562 {
563 if (!set_extension(ctx, name, GL_FALSE))
564 _mesa_problem(ctx, "Trying to disable unknown extension: %s", name);
565 }
566
567
568 /**
569 * Check if the i-th extension is enabled.
570 */
571 static GLboolean
572 extension_enabled(GLcontext *ctx, GLuint index)
573 {
574 const GLboolean *base = (const GLboolean *) &ctx->Extensions;
575 if (!default_extensions[index].flag_offset ||
576 *(base + default_extensions[index].flag_offset)) {
577 return GL_TRUE;
578 }
579 else {
580 return GL_FALSE;
581 }
582 }
583
584
585 /**
586 * Test if the named extension is enabled in this context.
587 */
588 GLboolean
589 _mesa_extension_is_enabled( GLcontext *ctx, const char *name )
590 {
591 GLuint i;
592
593 for (i = 0 ; i < Elements(default_extensions) ; i++) {
594 if (strcmp(default_extensions[i].name, name) == 0) {
595 return extension_enabled(ctx, i);
596 }
597 }
598 return GL_FALSE;
599 }
600
601
602 /**
603 * Append string 'b' onto string 'a'. Free 'a' and return new string.
604 */
605 static char *
606 append(const char *a, const char *b)
607 {
608 const GLuint aLen = a ? strlen(a) : 0;
609 const GLuint bLen = b ? strlen(b) : 0;
610 char *s = calloc(1, aLen + bLen + 1);
611 if (s) {
612 if (a)
613 memcpy(s, a, aLen);
614 if (b)
615 memcpy(s + aLen, b, bLen);
616 s[aLen + bLen] = '\0';
617 }
618 if (a)
619 free((void *) a);
620 return s;
621 }
622
623
624 /**
625 * Check the MESA_EXTENSION_OVERRIDE env var.
626 * For extension names that are recognized, turn them on. For extension
627 * names that are recognized and prefixed with '-', turn them off.
628 * Return a string of the unknown/leftover names.
629 */
630 static const char *
631 get_extension_override( GLcontext *ctx )
632 {
633 const char *envExt = _mesa_getenv("MESA_EXTENSION_OVERRIDE");
634 char *extraExt = NULL;
635 char ext[1000];
636 GLuint extLen = 0;
637 GLuint i;
638 GLboolean disableExt = GL_FALSE;
639
640 if (!envExt)
641 return NULL;
642
643 for (i = 0; ; i++) {
644 if (envExt[i] == '\0' || envExt[i] == ' ') {
645 /* terminate/process 'ext' if extLen > 0 */
646 if (extLen > 0) {
647 assert(extLen < sizeof(ext));
648 /* enable extension named by 'ext' */
649 ext[extLen] = 0;
650 if (!set_extension(ctx, ext, !disableExt)) {
651 /* unknown extension name, append it to extraExt */
652 if (extraExt) {
653 extraExt = append(extraExt, " ");
654 }
655 extraExt = append(extraExt, ext);
656 }
657 extLen = 0;
658 disableExt = GL_FALSE;
659 }
660 if (envExt[i] == '\0')
661 break;
662 }
663 else if (envExt[i] == '-') {
664 disableExt = GL_TRUE;
665 }
666 else {
667 /* accumulate this non-space character */
668 ext[extLen++] = envExt[i];
669 }
670 }
671
672 return extraExt;
673 }
674
675
676 /**
677 * Run through the default_extensions array above and set the
678 * ctx->Extensions.ARB/EXT_* flags accordingly.
679 * To be called during context initialization.
680 */
681 void
682 _mesa_init_extensions( GLcontext *ctx )
683 {
684 GLboolean *base = (GLboolean *) &ctx->Extensions;
685 GLuint i;
686
687 for (i = 0 ; i < Elements(default_extensions) ; i++) {
688 if (default_extensions[i].enabled &&
689 default_extensions[i].flag_offset) {
690 *(base + default_extensions[i].flag_offset) = GL_TRUE;
691 }
692 }
693 }
694
695
696 /**
697 * Construct the GL_EXTENSIONS string. Called the first time that
698 * glGetString(GL_EXTENSIONS) is called.
699 */
700 static GLubyte *
701 compute_extensions( GLcontext *ctx )
702 {
703 const char *extraExt = get_extension_override(ctx);
704 GLuint extStrLen = 0;
705 char *s;
706 GLuint i;
707
708 /* first, compute length of the extension string */
709 for (i = 0 ; i < Elements(default_extensions) ; i++) {
710 if (extension_enabled(ctx, i)) {
711 extStrLen += (GLuint) strlen(default_extensions[i].name) + 1;
712 }
713 }
714
715 if (extraExt)
716 extStrLen += strlen(extraExt) + 1; /* +1 for space */
717
718 /* allocate the extension string */
719 s = (char *) malloc(extStrLen);
720 if (!s)
721 return NULL;
722
723 /* second, build the extension string */
724 extStrLen = 0;
725 for (i = 0 ; i < Elements(default_extensions) ; i++) {
726 if (extension_enabled(ctx, i)) {
727 GLuint len = (GLuint) strlen(default_extensions[i].name);
728 memcpy(s + extStrLen, default_extensions[i].name, len);
729 extStrLen += len;
730 s[extStrLen] = ' ';
731 extStrLen++;
732 }
733 }
734 ASSERT(extStrLen > 0);
735
736 s[extStrLen - 1] = 0; /* -1 to overwrite trailing the ' ' */
737
738 if (extraExt) {
739 s = append(s, " ");
740 s = append(s, extraExt);
741 }
742
743 return (GLubyte *) s;
744 }
745
746 static size_t
747 append_extension(GLubyte **str, const char *ext)
748 {
749 GLubyte *s = *str;
750 size_t len = strlen(ext);
751
752 if (s) {
753 memcpy(s, ext, len);
754 s[len++] = ' ';
755 s[len] = '\0';
756
757 *str += len;
758 }
759 else {
760 len++;
761 }
762
763 return len;
764 }
765
766
767 static size_t
768 make_extension_string_es1(const GLcontext *ctx, GLubyte *str)
769 {
770 size_t len = 0;
771
772 /* Core additions */
773 len += append_extension(&str, "GL_OES_byte_coordinates");
774 len += append_extension(&str, "GL_OES_fixed_point");
775 len += append_extension(&str, "GL_OES_single_precision");
776 len += append_extension(&str, "GL_OES_matrix_get");
777
778 /* 1.1 required extensions */
779 len += append_extension(&str, "GL_OES_read_format");
780 len += append_extension(&str, "GL_OES_compressed_paletted_texture");
781 len += append_extension(&str, "GL_OES_point_size_array");
782 len += append_extension(&str, "GL_OES_point_sprite");
783
784 /* 1.1 deprecated extensions */
785 len += append_extension(&str, "GL_OES_query_matrix");
786
787 #if FEATURE_OES_draw_texture
788 if (ctx->Extensions.OES_draw_texture)
789 len += append_extension(&str, "GL_OES_draw_texture");
790 #endif
791
792 if (ctx->Extensions.EXT_blend_equation_separate)
793 len += append_extension(&str, "GL_OES_blend_equation_separate");
794 if (ctx->Extensions.EXT_blend_func_separate)
795 len += append_extension(&str, "GL_OES_blend_func_separate");
796 if (ctx->Extensions.EXT_blend_subtract)
797 len += append_extension(&str, "GL_OES_blend_subtract");
798
799 if (ctx->Extensions.EXT_stencil_wrap)
800 len += append_extension(&str, "GL_OES_stencil_wrap");
801
802 if (ctx->Extensions.ARB_texture_cube_map)
803 len += append_extension(&str, "GL_OES_texture_cube_map");
804 if (ctx->Extensions.ARB_texture_env_crossbar)
805 len += append_extension(&str, "GL_OES_texture_env_crossbar");
806 if (ctx->Extensions.ARB_texture_mirrored_repeat)
807 len += append_extension(&str, "GL_OES_texture_mirrored_repeat");
808
809 if (ctx->Extensions.ARB_framebuffer_object) {
810 len += append_extension(&str, "GL_OES_framebuffer_object");
811 len += append_extension(&str, "GL_OES_depth24");
812 len += append_extension(&str, "GL_OES_depth32");
813 len += append_extension(&str, "GL_OES_fbo_render_mipmap");
814 len += append_extension(&str, "GL_OES_rgb8_rgba8");
815 len += append_extension(&str, "GL_OES_stencil1");
816 len += append_extension(&str, "GL_OES_stencil4");
817 len += append_extension(&str, "GL_OES_stencil8");
818 }
819
820 if (ctx->Extensions.EXT_vertex_array)
821 len += append_extension(&str, "GL_OES_element_index_uint");
822 if (ctx->Extensions.ARB_vertex_buffer_object)
823 len += append_extension(&str, "GL_OES_mapbuffer");
824 if (ctx->Extensions.EXT_texture_filter_anisotropic)
825 len += append_extension(&str, "GL_EXT_texture_filter_anisotropic");
826
827 /* some applications check this for NPOT support */
828 if (ctx->Extensions.ARB_texture_non_power_of_two)
829 len += append_extension(&str, "GL_ARB_texture_non_power_of_two");
830
831 if (ctx->Extensions.EXT_texture_compression_s3tc)
832 len += append_extension(&str, "GL_EXT_texture_compression_dxt1");
833 if (ctx->Extensions.EXT_texture_lod_bias)
834 len += append_extension(&str, "GL_EXT_texture_lod_bias");
835 if (ctx->Extensions.EXT_blend_minmax)
836 len += append_extension(&str, "GL_EXT_blend_minmax");
837 if (ctx->Extensions.EXT_multi_draw_arrays)
838 len += append_extension(&str, "GL_EXT_multi_draw_arrays");
839
840 #if FEATURE_OES_EGL_image
841 if (ctx->Extensions.OES_EGL_image)
842 len += append_extension(&str, "GL_OES_EGL_image");
843 #endif
844
845 return len;
846 }
847
848
849 static GLubyte *
850 compute_extensions_es1(const GLcontext *ctx)
851 {
852 GLubyte *s;
853 unsigned int len;
854
855 len = make_extension_string_es1(ctx, NULL);
856 s = malloc(len + 1);
857 if (!s)
858 return NULL;
859 make_extension_string_es1(ctx, s);
860
861 return s;
862 }
863
864 static size_t
865 make_extension_string_es2(const GLcontext *ctx, GLubyte *str)
866 {
867 size_t len = 0;
868
869 len += append_extension(&str, "GL_OES_compressed_paletted_texture");
870
871 if (ctx->Extensions.ARB_framebuffer_object) {
872 len += append_extension(&str, "GL_OES_depth24");
873 len += append_extension(&str, "GL_OES_depth32");
874 len += append_extension(&str, "GL_OES_fbo_render_mipmap");
875 len += append_extension(&str, "GL_OES_rgb8_rgba8");
876 len += append_extension(&str, "GL_OES_stencil1");
877 len += append_extension(&str, "GL_OES_stencil4");
878 }
879
880 if (ctx->Extensions.EXT_vertex_array)
881 len += append_extension(&str, "GL_OES_element_index_uint");
882 if (ctx->Extensions.ARB_vertex_buffer_object)
883 len += append_extension(&str, "GL_OES_mapbuffer");
884
885 if (ctx->Extensions.EXT_texture3D)
886 len += append_extension(&str, "GL_OES_texture_3D");
887 if (ctx->Extensions.ARB_texture_non_power_of_two)
888 len += append_extension(&str, "GL_OES_texture_npot");
889 if (ctx->Extensions.EXT_texture_filter_anisotropic)
890 len += append_extension(&str, "GL_EXT_texture_filter_anisotropic");
891
892 len += append_extension(&str, "GL_EXT_texture_type_2_10_10_10_REV");
893 if (ctx->Extensions.ARB_depth_texture)
894 len += append_extension(&str, "GL_OES_depth_texture");
895 if (ctx->Extensions.EXT_packed_depth_stencil)
896 len += append_extension(&str, "GL_OES_packed_depth_stencil");
897 if (ctx->Extensions.ARB_fragment_shader)
898 len += append_extension(&str, "GL_OES_standard_derivatives");
899
900 if (ctx->Extensions.EXT_texture_compression_s3tc)
901 len += append_extension(&str, "GL_EXT_texture_compression_dxt1");
902 if (ctx->Extensions.EXT_blend_minmax)
903 len += append_extension(&str, "GL_EXT_blend_minmax");
904 if (ctx->Extensions.EXT_multi_draw_arrays)
905 len += append_extension(&str, "GL_EXT_multi_draw_arrays");
906
907 #if FEATURE_OES_EGL_image
908 if (ctx->Extensions.OES_EGL_image)
909 len += append_extension(&str, "GL_OES_EGL_image");
910 #endif
911
912 return len;
913 }
914
915 static GLubyte *
916 compute_extensions_es2(GLcontext *ctx)
917 {
918 GLubyte *s;
919 unsigned int len;
920
921 len = make_extension_string_es2(ctx, NULL);
922 s = malloc(len + 1);
923 if (!s)
924 return NULL;
925 make_extension_string_es2(ctx, s);
926
927 return s;
928 }
929
930
931 GLubyte *
932 _mesa_make_extension_string(GLcontext *ctx)
933 {
934 switch (ctx->API) {
935 case API_OPENGL:
936 return compute_extensions(ctx);
937 case API_OPENGLES2:
938 return compute_extensions_es2(ctx);
939 case API_OPENGLES:
940 return compute_extensions_es1(ctx);
941 default:
942 assert(0);
943 return NULL;
944 }
945 }
946
947 /**
948 * Return number of enabled extensions.
949 */
950 GLuint
951 _mesa_get_extension_count(GLcontext *ctx)
952 {
953 GLuint i;
954
955 /* only count once */
956 if (!ctx->Extensions.Count) {
957 for (i = 0; i < Elements(default_extensions); i++) {
958 if (extension_enabled(ctx, i)) {
959 ctx->Extensions.Count++;
960 }
961 }
962 }
963
964 if (0)
965 _mesa_debug(ctx, "%u of %d extensions enabled\n", ctx->Extensions.Count,
966 (int) Elements(default_extensions));
967
968 return ctx->Extensions.Count;
969 }
970
971
972 /**
973 * Return name of i-th enabled extension
974 */
975 const GLubyte *
976 _mesa_get_enabled_extension(GLcontext *ctx, GLuint index)
977 {
978 GLuint i;
979
980 for (i = 0; i < Elements(default_extensions); i++) {
981 if (extension_enabled(ctx, i)) {
982 if (index == 0)
983 return (const GLubyte *) default_extensions[i].name;
984 index--;
985 }
986 }
987
988 return NULL;
989 }