mesa: fix some printf warnings with casts
[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 { OFF, "GL_ARB_geometry_shader4", F(ARB_geometry_shader4) },
62 { OFF, "GL_ARB_half_float_pixel", F(ARB_half_float_pixel) },
63 { OFF, "GL_ARB_half_float_vertex", F(ARB_half_float_vertex) },
64 { OFF, "GL_ARB_imaging", F(ARB_imaging) },
65 { OFF, "GL_ARB_instanced_arrays", F(ARB_instanced_arrays) },
66 { OFF, "GL_ARB_map_buffer_range", F(ARB_map_buffer_range) },
67 { ON, "GL_ARB_multisample", F(ARB_multisample) },
68 { OFF, "GL_ARB_multitexture", F(ARB_multitexture) },
69 { OFF, "GL_ARB_occlusion_query", F(ARB_occlusion_query) },
70 { OFF, "GL_ARB_occlusion_query2", F(ARB_occlusion_query2) },
71 { OFF, "GL_ARB_pixel_buffer_object", F(EXT_pixel_buffer_object) },
72 { OFF, "GL_ARB_point_parameters", F(EXT_point_parameters) },
73 { OFF, "GL_ARB_point_sprite", F(ARB_point_sprite) },
74 { OFF, "GL_ARB_provoking_vertex", F(EXT_provoking_vertex) },
75 { OFF, "GL_ARB_sampler_objects", F(ARB_sampler_objects) },
76 { OFF, "GL_ARB_seamless_cube_map", F(ARB_seamless_cube_map) },
77 { OFF, "GL_ARB_shader_objects", F(ARB_shader_objects) },
78 { OFF, "GL_ARB_shading_language_100", F(ARB_shading_language_100) },
79 { OFF, "GL_ARB_shading_language_120", F(ARB_shading_language_120) },
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 #if FEATURE_ARB_shading_language_120
272 ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
273 #endif
274 ctx->Extensions.ARB_shadow = GL_TRUE;
275 ctx->Extensions.ARB_shadow_ambient = GL_TRUE;
276 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
277 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
278 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
279 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
280 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
281 /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/
282 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
283 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
284 ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
285 #if FEATURE_ARB_vertex_program
286 ctx->Extensions.ARB_vertex_program = GL_TRUE;
287 #endif
288 #if FEATURE_ARB_vertex_shader
289 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
290 #endif
291 #if FEATURE_ARB_vertex_buffer_object
292 /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
293 #endif
294 #if FEATURE_ARB_sync
295 ctx->Extensions.ARB_sync = GL_TRUE;
296 #endif
297 ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
298 #if FEATURE_APPLE_object_purgeable
299 ctx->Extensions.APPLE_object_purgeable = GL_TRUE;
300 #endif
301 ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE;
302 #if FEATURE_ATI_fragment_shader
303 ctx->Extensions.ATI_fragment_shader = GL_TRUE;
304 #endif
305 ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
306 ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
307 ctx->Extensions.ATI_separate_stencil = GL_TRUE;
308 ctx->Extensions.EXT_blend_color = GL_TRUE;
309 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
310 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
311 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
312 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
313 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
314 ctx->Extensions.EXT_convolution = GL_TRUE;
315 ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
316 ctx->Extensions.EXT_draw_buffers2 = GL_TRUE;
317 ctx->Extensions.EXT_fog_coord = GL_TRUE;
318 #if FEATURE_EXT_framebuffer_object
319 ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
320 #endif
321 #if FEATURE_EXT_framebuffer_blit
322 ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
323 #endif
324 #if FEATURE_ARB_framebuffer_object
325 ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE;
326 #endif
327 ctx->Extensions.EXT_histogram = GL_TRUE;
328 /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
329 ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
330 ctx->Extensions.EXT_paletted_texture = GL_TRUE;
331 #if FEATURE_EXT_pixel_buffer_object
332 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
333 #endif
334 ctx->Extensions.EXT_point_parameters = GL_TRUE;
335 ctx->Extensions.EXT_provoking_vertex = GL_TRUE;
336 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
337 ctx->Extensions.EXT_secondary_color = GL_TRUE;
338 ctx->Extensions.EXT_shared_texture_palette = GL_TRUE;
339 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
340 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
341 ctx->Extensions.EXT_texture_array = GL_TRUE;
342 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
343 ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
344 ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
345 ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
346 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
347 #if FEATURE_EXT_texture_sRGB
348 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
349 #endif
350 ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
351 #if FEATURE_EXT_transform_feedback
352 /*ctx->Extensions.EXT_transform_feedback = GL_TRUE;*/
353 #endif
354 ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
355 /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/
356 ctx->Extensions.MESA_pack_invert = GL_TRUE;
357 ctx->Extensions.MESA_resize_buffers = GL_TRUE;
358 ctx->Extensions.MESA_texture_array = GL_TRUE;
359 ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
360 ctx->Extensions.NV_blend_square = GL_TRUE;
361 ctx->Extensions.NV_conditional_render = GL_TRUE;
362 /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/
363 ctx->Extensions.NV_point_sprite = GL_TRUE;
364 ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
365 ctx->Extensions.NV_texture_rectangle = GL_TRUE;
366 /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/
367 #if FEATURE_NV_vertex_program
368 ctx->Extensions.NV_vertex_program = GL_TRUE;
369 ctx->Extensions.NV_vertex_program1_1 = GL_TRUE;
370 #endif
371 #if FEATURE_NV_fragment_program
372 ctx->Extensions.NV_fragment_program = GL_TRUE;
373 #endif
374 #if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program
375 ctx->Extensions.NV_fragment_program_option = GL_TRUE;
376 #endif
377 ctx->Extensions.SGI_color_matrix = GL_TRUE;
378 ctx->Extensions.SGI_color_table = GL_TRUE;
379 ctx->Extensions.SGI_texture_color_table = GL_TRUE;
380 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
381 ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE;
382 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
383 ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE;
384 #endif
385 #if FEATURE_texture_fxt1
386 _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
387 #endif
388 #if FEATURE_texture_s3tc
389 if (ctx->Mesa_DXTn) {
390 _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
391 _mesa_enable_extension(ctx, "GL_S3_s3tc");
392 }
393 #endif
394 }
395
396
397 /**
398 * Enable GL_ARB_imaging and all the EXT extensions that are subsets of it.
399 */
400 void
401 _mesa_enable_imaging_extensions(GLcontext *ctx)
402 {
403 ctx->Extensions.ARB_imaging = GL_TRUE;
404 ctx->Extensions.EXT_blend_color = GL_TRUE;
405 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
406 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
407 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
408 ctx->Extensions.EXT_convolution = GL_TRUE;
409 ctx->Extensions.EXT_histogram = GL_TRUE;
410 ctx->Extensions.SGI_color_matrix = GL_TRUE;
411 ctx->Extensions.SGI_color_table = GL_TRUE;
412 }
413
414
415
416 /**
417 * Enable all OpenGL 1.3 features and extensions.
418 * A convenience function to be called by drivers.
419 */
420 void
421 _mesa_enable_1_3_extensions(GLcontext *ctx)
422 {
423 /*ctx->Extensions.ARB_multisample = GL_TRUE;*/
424 ctx->Extensions.ARB_multitexture = GL_TRUE;
425 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
426 /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/
427 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
428 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
429 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
430 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
431 /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/
432 }
433
434
435
436 /**
437 * Enable all OpenGL 1.4 features and extensions.
438 * A convenience function to be called by drivers.
439 */
440 void
441 _mesa_enable_1_4_extensions(GLcontext *ctx)
442 {
443 ctx->Extensions.ARB_depth_texture = GL_TRUE;
444 ctx->Extensions.ARB_shadow = GL_TRUE;
445 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
446 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
447 ctx->Extensions.ARB_window_pos = GL_TRUE;
448 ctx->Extensions.EXT_blend_color = GL_TRUE;
449 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
450 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
451 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
452 ctx->Extensions.EXT_fog_coord = GL_TRUE;
453 /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
454 ctx->Extensions.EXT_point_parameters = GL_TRUE;
455 ctx->Extensions.EXT_secondary_color = GL_TRUE;
456 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
457 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
458 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
459 }
460
461
462 /**
463 * Enable all OpenGL 1.5 features and extensions.
464 * A convenience function to be called by drivers.
465 */
466 void
467 _mesa_enable_1_5_extensions(GLcontext *ctx)
468 {
469 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
470 /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
471 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
472 }
473
474
475 /**
476 * Enable all OpenGL 2.0 features and extensions.
477 * A convenience function to be called by drivers.
478 */
479 void
480 _mesa_enable_2_0_extensions(GLcontext *ctx)
481 {
482 /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
483 #if FEATURE_ARB_fragment_shader
484 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
485 #endif
486 ctx->Extensions.ARB_point_sprite = GL_TRUE;
487 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
488 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
489 #if FEATURE_ARB_shader_objects
490 ctx->Extensions.ARB_shader_objects = GL_TRUE;
491 #endif
492 #if FEATURE_ARB_shading_language_100
493 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
494 #endif
495 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
496 #if FEATURE_ARB_vertex_shader
497 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
498 #endif
499 }
500
501
502 /**
503 * Enable all OpenGL 2.1 features and extensions.
504 * A convenience function to be called by drivers.
505 */
506 void
507 _mesa_enable_2_1_extensions(GLcontext *ctx)
508 {
509 #if FEATURE_EXT_pixel_buffer_object
510 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
511 #endif
512 #if FEATURE_EXT_texture_sRGB
513 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
514 #endif
515 #if FEATURE_ARB_shading_language_120
516 ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
517 #endif
518 }
519
520
521 /**
522 * Either enable or disable the named extension.
523 * \return GL_TRUE for success, GL_FALSE if invalid extension name
524 */
525 static GLboolean
526 set_extension( GLcontext *ctx, const char *name, GLboolean state )
527 {
528 GLboolean *base = (GLboolean *) &ctx->Extensions;
529 GLuint i;
530
531 if (ctx->Extensions.String) {
532 /* The string was already queried - can't change it now! */
533 _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name);
534 return GL_FALSE;
535 }
536
537 for (i = 0 ; i < Elements(default_extensions) ; i++) {
538 if (strcmp(default_extensions[i].name, name) == 0) {
539 if (default_extensions[i].flag_offset) {
540 GLboolean *enabled = base + default_extensions[i].flag_offset;
541 *enabled = state;
542 }
543 return GL_TRUE;
544 }
545 }
546 return GL_FALSE;
547 }
548
549
550 /**
551 * Enable the named extension.
552 * Typically called by drivers.
553 */
554 void
555 _mesa_enable_extension( GLcontext *ctx, const char *name )
556 {
557 if (!set_extension(ctx, name, GL_TRUE))
558 _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
559 }
560
561
562 /**
563 * Disable the named extension.
564 * XXX is this really needed???
565 */
566 void
567 _mesa_disable_extension( GLcontext *ctx, const char *name )
568 {
569 if (!set_extension(ctx, name, GL_FALSE))
570 _mesa_problem(ctx, "Trying to disable unknown extension: %s", name);
571 }
572
573
574 /**
575 * Check if the i-th extension is enabled.
576 */
577 static GLboolean
578 extension_enabled(GLcontext *ctx, GLuint index)
579 {
580 const GLboolean *base = (const GLboolean *) &ctx->Extensions;
581 if (!default_extensions[index].flag_offset ||
582 *(base + default_extensions[index].flag_offset)) {
583 return GL_TRUE;
584 }
585 else {
586 return GL_FALSE;
587 }
588 }
589
590
591 /**
592 * Test if the named extension is enabled in this context.
593 */
594 GLboolean
595 _mesa_extension_is_enabled( GLcontext *ctx, const char *name )
596 {
597 GLuint i;
598
599 for (i = 0 ; i < Elements(default_extensions) ; i++) {
600 if (strcmp(default_extensions[i].name, name) == 0) {
601 return extension_enabled(ctx, i);
602 }
603 }
604 return GL_FALSE;
605 }
606
607
608 /**
609 * Append string 'b' onto string 'a'. Free 'a' and return new string.
610 */
611 static char *
612 append(const char *a, const char *b)
613 {
614 const GLuint aLen = a ? strlen(a) : 0;
615 const GLuint bLen = b ? strlen(b) : 0;
616 char *s = calloc(1, aLen + bLen + 1);
617 if (s) {
618 if (a)
619 memcpy(s, a, aLen);
620 if (b)
621 memcpy(s + aLen, b, bLen);
622 s[aLen + bLen] = '\0';
623 }
624 if (a)
625 free((void *) a);
626 return s;
627 }
628
629
630 /**
631 * Check the MESA_EXTENSION_OVERRIDE env var.
632 * For extension names that are recognized, turn them on. For extension
633 * names that are recognized and prefixed with '-', turn them off.
634 * Return a string of the unknown/leftover names.
635 */
636 static const char *
637 get_extension_override( GLcontext *ctx )
638 {
639 const char *envExt = _mesa_getenv("MESA_EXTENSION_OVERRIDE");
640 char *extraExt = NULL;
641 char ext[1000];
642 GLuint extLen = 0;
643 GLuint i;
644 GLboolean disableExt = GL_FALSE;
645
646 if (!envExt)
647 return NULL;
648
649 for (i = 0; ; i++) {
650 if (envExt[i] == '\0' || envExt[i] == ' ') {
651 /* terminate/process 'ext' if extLen > 0 */
652 if (extLen > 0) {
653 assert(extLen < sizeof(ext));
654 /* enable extension named by 'ext' */
655 ext[extLen] = 0;
656 if (!set_extension(ctx, ext, !disableExt)) {
657 /* unknown extension name, append it to extraExt */
658 if (extraExt) {
659 extraExt = append(extraExt, " ");
660 }
661 extraExt = append(extraExt, ext);
662 }
663 extLen = 0;
664 disableExt = GL_FALSE;
665 }
666 if (envExt[i] == '\0')
667 break;
668 }
669 else if (envExt[i] == '-') {
670 disableExt = GL_TRUE;
671 }
672 else {
673 /* accumulate this non-space character */
674 ext[extLen++] = envExt[i];
675 }
676 }
677
678 return extraExt;
679 }
680
681
682 /**
683 * Run through the default_extensions array above and set the
684 * ctx->Extensions.ARB/EXT_* flags accordingly.
685 * To be called during context initialization.
686 */
687 void
688 _mesa_init_extensions( GLcontext *ctx )
689 {
690 GLboolean *base = (GLboolean *) &ctx->Extensions;
691 GLuint i;
692
693 for (i = 0 ; i < Elements(default_extensions) ; i++) {
694 if (default_extensions[i].enabled &&
695 default_extensions[i].flag_offset) {
696 *(base + default_extensions[i].flag_offset) = GL_TRUE;
697 }
698 }
699 }
700
701
702 /**
703 * Construct the GL_EXTENSIONS string. Called the first time that
704 * glGetString(GL_EXTENSIONS) is called.
705 */
706 static GLubyte *
707 compute_extensions( GLcontext *ctx )
708 {
709 const char *extraExt = get_extension_override(ctx);
710 GLuint extStrLen = 0;
711 char *s;
712 GLuint i;
713
714 /* first, compute length of the extension string */
715 for (i = 0 ; i < Elements(default_extensions) ; i++) {
716 if (extension_enabled(ctx, i)) {
717 extStrLen += (GLuint) strlen(default_extensions[i].name) + 1;
718 }
719 }
720
721 if (extraExt)
722 extStrLen += strlen(extraExt) + 1; /* +1 for space */
723
724 /* allocate the extension string */
725 s = (char *) malloc(extStrLen);
726 if (!s)
727 return NULL;
728
729 /* second, build the extension string */
730 extStrLen = 0;
731 for (i = 0 ; i < Elements(default_extensions) ; i++) {
732 if (extension_enabled(ctx, i)) {
733 GLuint len = (GLuint) strlen(default_extensions[i].name);
734 memcpy(s + extStrLen, default_extensions[i].name, len);
735 extStrLen += len;
736 s[extStrLen] = ' ';
737 extStrLen++;
738 }
739 }
740 ASSERT(extStrLen > 0);
741
742 s[extStrLen - 1] = 0; /* -1 to overwrite trailing the ' ' */
743
744 if (extraExt) {
745 s = append(s, " ");
746 s = append(s, extraExt);
747 }
748
749 return (GLubyte *) s;
750 }
751
752 static size_t
753 append_extension(GLubyte **str, const char *ext)
754 {
755 GLubyte *s = *str;
756 size_t len = strlen(ext);
757
758 if (s) {
759 memcpy(s, ext, len);
760 s[len++] = ' ';
761 s[len] = '\0';
762
763 *str += len;
764 }
765 else {
766 len++;
767 }
768
769 return len;
770 }
771
772
773 static size_t
774 make_extension_string_es1(const GLcontext *ctx, GLubyte *str)
775 {
776 size_t len = 0;
777
778 /* Core additions */
779 len += append_extension(&str, "GL_OES_byte_coordinates");
780 len += append_extension(&str, "GL_OES_fixed_point");
781 len += append_extension(&str, "GL_OES_single_precision");
782 len += append_extension(&str, "GL_OES_matrix_get");
783
784 /* 1.1 required extensions */
785 len += append_extension(&str, "GL_OES_read_format");
786 len += append_extension(&str, "GL_OES_compressed_paletted_texture");
787 len += append_extension(&str, "GL_OES_point_size_array");
788 len += append_extension(&str, "GL_OES_point_sprite");
789
790 /* 1.1 deprecated extensions */
791 len += append_extension(&str, "GL_OES_query_matrix");
792
793 #if FEATURE_OES_draw_texture
794 if (ctx->Extensions.OES_draw_texture)
795 len += append_extension(&str, "GL_OES_draw_texture");
796 #endif
797
798 if (ctx->Extensions.EXT_blend_equation_separate)
799 len += append_extension(&str, "GL_OES_blend_equation_separate");
800 if (ctx->Extensions.EXT_blend_func_separate)
801 len += append_extension(&str, "GL_OES_blend_func_separate");
802 if (ctx->Extensions.EXT_blend_subtract)
803 len += append_extension(&str, "GL_OES_blend_subtract");
804
805 if (ctx->Extensions.EXT_stencil_wrap)
806 len += append_extension(&str, "GL_OES_stencil_wrap");
807
808 if (ctx->Extensions.ARB_texture_cube_map)
809 len += append_extension(&str, "GL_OES_texture_cube_map");
810 if (ctx->Extensions.ARB_texture_env_crossbar)
811 len += append_extension(&str, "GL_OES_texture_env_crossbar");
812 if (ctx->Extensions.ARB_texture_mirrored_repeat)
813 len += append_extension(&str, "GL_OES_texture_mirrored_repeat");
814
815 if (ctx->Extensions.ARB_framebuffer_object) {
816 len += append_extension(&str, "GL_OES_framebuffer_object");
817 len += append_extension(&str, "GL_OES_depth24");
818 len += append_extension(&str, "GL_OES_depth32");
819 len += append_extension(&str, "GL_OES_fbo_render_mipmap");
820 len += append_extension(&str, "GL_OES_rgb8_rgba8");
821 len += append_extension(&str, "GL_OES_stencil1");
822 len += append_extension(&str, "GL_OES_stencil4");
823 len += append_extension(&str, "GL_OES_stencil8");
824 }
825
826 if (ctx->Extensions.EXT_vertex_array)
827 len += append_extension(&str, "GL_OES_element_index_uint");
828 if (ctx->Extensions.ARB_vertex_buffer_object)
829 len += append_extension(&str, "GL_OES_mapbuffer");
830 if (ctx->Extensions.EXT_texture_filter_anisotropic)
831 len += append_extension(&str, "GL_EXT_texture_filter_anisotropic");
832
833 /* some applications check this for NPOT support */
834 if (ctx->Extensions.ARB_texture_non_power_of_two)
835 len += append_extension(&str, "GL_ARB_texture_non_power_of_two");
836
837 if (ctx->Extensions.EXT_texture_compression_s3tc)
838 len += append_extension(&str, "GL_EXT_texture_compression_dxt1");
839 if (ctx->Extensions.EXT_texture_lod_bias)
840 len += append_extension(&str, "GL_EXT_texture_lod_bias");
841 if (ctx->Extensions.EXT_blend_minmax)
842 len += append_extension(&str, "GL_EXT_blend_minmax");
843 if (ctx->Extensions.EXT_multi_draw_arrays)
844 len += append_extension(&str, "GL_EXT_multi_draw_arrays");
845
846 #if FEATURE_OES_EGL_image
847 if (ctx->Extensions.OES_EGL_image)
848 len += append_extension(&str, "GL_OES_EGL_image");
849 #endif
850
851 return len;
852 }
853
854
855 static GLubyte *
856 compute_extensions_es1(const GLcontext *ctx)
857 {
858 GLubyte *s;
859 unsigned int len;
860
861 len = make_extension_string_es1(ctx, NULL);
862 s = malloc(len + 1);
863 if (!s)
864 return NULL;
865 make_extension_string_es1(ctx, s);
866
867 return s;
868 }
869
870 static size_t
871 make_extension_string_es2(const GLcontext *ctx, GLubyte *str)
872 {
873 size_t len = 0;
874
875 len += append_extension(&str, "GL_OES_compressed_paletted_texture");
876
877 if (ctx->Extensions.ARB_framebuffer_object) {
878 len += append_extension(&str, "GL_OES_depth24");
879 len += append_extension(&str, "GL_OES_depth32");
880 len += append_extension(&str, "GL_OES_fbo_render_mipmap");
881 len += append_extension(&str, "GL_OES_rgb8_rgba8");
882 len += append_extension(&str, "GL_OES_stencil1");
883 len += append_extension(&str, "GL_OES_stencil4");
884 }
885
886 if (ctx->Extensions.EXT_vertex_array)
887 len += append_extension(&str, "GL_OES_element_index_uint");
888 if (ctx->Extensions.ARB_vertex_buffer_object)
889 len += append_extension(&str, "GL_OES_mapbuffer");
890
891 if (ctx->Extensions.EXT_texture3D)
892 len += append_extension(&str, "GL_OES_texture_3D");
893 if (ctx->Extensions.ARB_texture_non_power_of_two)
894 len += append_extension(&str, "GL_OES_texture_npot");
895 if (ctx->Extensions.EXT_texture_filter_anisotropic)
896 len += append_extension(&str, "GL_EXT_texture_filter_anisotropic");
897
898 len += append_extension(&str, "GL_EXT_texture_type_2_10_10_10_REV");
899 if (ctx->Extensions.ARB_depth_texture)
900 len += append_extension(&str, "GL_OES_depth_texture");
901 if (ctx->Extensions.EXT_packed_depth_stencil)
902 len += append_extension(&str, "GL_OES_packed_depth_stencil");
903 if (ctx->Extensions.ARB_fragment_shader)
904 len += append_extension(&str, "GL_OES_standard_derivatives");
905
906 if (ctx->Extensions.EXT_texture_compression_s3tc)
907 len += append_extension(&str, "GL_EXT_texture_compression_dxt1");
908 if (ctx->Extensions.EXT_blend_minmax)
909 len += append_extension(&str, "GL_EXT_blend_minmax");
910 if (ctx->Extensions.EXT_multi_draw_arrays)
911 len += append_extension(&str, "GL_EXT_multi_draw_arrays");
912
913 #if FEATURE_OES_EGL_image
914 if (ctx->Extensions.OES_EGL_image)
915 len += append_extension(&str, "GL_OES_EGL_image");
916 #endif
917
918 return len;
919 }
920
921 static GLubyte *
922 compute_extensions_es2(GLcontext *ctx)
923 {
924 GLubyte *s;
925 unsigned int len;
926
927 len = make_extension_string_es2(ctx, NULL);
928 s = malloc(len + 1);
929 if (!s)
930 return NULL;
931 make_extension_string_es2(ctx, s);
932
933 return s;
934 }
935
936
937 GLubyte *
938 _mesa_make_extension_string(GLcontext *ctx)
939 {
940 switch (ctx->API) {
941 case API_OPENGL:
942 return compute_extensions(ctx);
943 case API_OPENGLES2:
944 return compute_extensions_es2(ctx);
945 case API_OPENGLES:
946 return compute_extensions_es1(ctx);
947 default:
948 assert(0);
949 return NULL;
950 }
951 }
952
953 /**
954 * Return number of enabled extensions.
955 */
956 GLuint
957 _mesa_get_extension_count(GLcontext *ctx)
958 {
959 GLuint i;
960
961 /* only count once */
962 if (!ctx->Extensions.Count) {
963 for (i = 0; i < Elements(default_extensions); i++) {
964 if (extension_enabled(ctx, i)) {
965 ctx->Extensions.Count++;
966 }
967 }
968 }
969
970 if (0)
971 _mesa_debug(ctx, "%u of %d extensions enabled\n", ctx->Extensions.Count,
972 (int) Elements(default_extensions));
973
974 return ctx->Extensions.Count;
975 }
976
977
978 /**
979 * Return name of i-th enabled extension
980 */
981 const GLubyte *
982 _mesa_get_enabled_extension(GLcontext *ctx, GLuint index)
983 {
984 GLuint i;
985
986 for (i = 0; i < Elements(default_extensions); i++) {
987 if (extension_enabled(ctx, i)) {
988 if (index == 0)
989 return (const GLubyte *) default_extensions[i].name;
990 index--;
991 }
992 }
993
994 return NULL;
995 }