Merge commit 'origin/gallium-master-merge'
[mesa.git] / src / mesa / main / extensions.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.3
4 *
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 #include "glheader.h"
27 #include "imports.h"
28 #include "context.h"
29 #include "extensions.h"
30 #include "simple_list.h"
31 #include "mtypes.h"
32
33
34 #define F(x) (int)(uintptr_t)&(((struct gl_extensions *)0)->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_depth_texture", F(ARB_depth_texture) },
48 { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) },
49 { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) },
50 { OFF, "GL_ARB_fragment_program_shadow", F(ARB_fragment_program_shadow) },
51 { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) },
52 { OFF, "GL_ARB_framebuffer_object", F(ARB_framebuffer_object) },
53 { OFF, "GL_ARB_half_float_pixel", F(ARB_half_float_pixel) },
54 { OFF, "GL_ARB_imaging", F(ARB_imaging) },
55 { ON, "GL_ARB_multisample", F(ARB_multisample) },
56 { OFF, "GL_ARB_multitexture", F(ARB_multitexture) },
57 { OFF, "GL_ARB_occlusion_query", F(ARB_occlusion_query) },
58 { OFF, "GL_ARB_pixel_buffer_object", F(EXT_pixel_buffer_object) },
59 { OFF, "GL_ARB_point_parameters", F(EXT_point_parameters) },
60 { OFF, "GL_ARB_point_sprite", F(ARB_point_sprite) },
61 { OFF, "GL_ARB_shader_objects", F(ARB_shader_objects) },
62 { OFF, "GL_ARB_shading_language_100", F(ARB_shading_language_100) },
63 { OFF, "GL_ARB_shading_language_120", F(ARB_shading_language_120) },
64 { OFF, "GL_ARB_shadow", F(ARB_shadow) },
65 { OFF, "GL_ARB_shadow_ambient", F(ARB_shadow_ambient) },
66 { OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) },
67 { ON, "GL_ARB_texture_compression", F(ARB_texture_compression) },
68 { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) },
69 { OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) },
70 { OFF, "GL_ARB_texture_env_combine", F(ARB_texture_env_combine) },
71 { OFF, "GL_ARB_texture_env_crossbar", F(ARB_texture_env_crossbar) },
72 { OFF, "GL_ARB_texture_env_dot3", F(ARB_texture_env_dot3) },
73 { OFF, "GL_MESAX_texture_float", F(ARB_texture_float) },
74 { OFF, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
75 { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)},
76 { OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) },
77 { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) },
78 { ON, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) },
79 { OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) },
80 { OFF, "GL_ARB_vertex_shader", F(ARB_vertex_shader) },
81 { ON, "GL_ARB_window_pos", F(ARB_window_pos) },
82 { ON, "GL_EXT_abgr", F(EXT_abgr) },
83 { ON, "GL_EXT_bgra", F(EXT_bgra) },
84 { OFF, "GL_EXT_blend_color", F(EXT_blend_color) },
85 { OFF, "GL_EXT_blend_equation_separate", F(EXT_blend_equation_separate) },
86 { OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) },
87 { OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) },
88 { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) },
89 { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) },
90 { OFF, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) },
91 { OFF, "GL_EXT_cull_vertex", F(EXT_cull_vertex) },
92 { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) },
93 { OFF, "GL_EXT_convolution", F(EXT_convolution) },
94 { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) },
95 { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) },
96 { ON, "GL_EXT_draw_range_elements", F(EXT_draw_range_elements) },
97 { OFF, "GL_EXT_framebuffer_object", F(EXT_framebuffer_object) },
98 { OFF, "GL_EXT_framebuffer_blit", F(EXT_framebuffer_blit) },
99 { OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) },
100 { OFF, "GL_EXT_gpu_program_parameters", F(EXT_gpu_program_parameters) },
101 { OFF, "GL_EXT_histogram", F(EXT_histogram) },
102 { ON, "GL_EXT_multi_draw_arrays", F(EXT_multi_draw_arrays) },
103 { OFF, "GL_EXT_packed_depth_stencil", F(EXT_packed_depth_stencil) },
104 { ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) },
105 { OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) },
106 { OFF, "GL_EXT_pixel_buffer_object", F(EXT_pixel_buffer_object) },
107 { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) },
108 { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) },
109 { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) },
110 { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) },
111 { ON, "GL_EXT_separate_specular_color", F(EXT_separate_specular_color) },
112 { OFF, "GL_EXT_shadow_funcs", F(EXT_shadow_funcs) },
113 { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) },
114 { OFF, "GL_EXT_stencil_two_side", F(EXT_stencil_two_side) },
115 { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) },
116 { ON, "GL_EXT_subtexture", F(EXT_subtexture) },
117 { ON, "GL_EXT_texture", F(EXT_texture) },
118 { ON, "GL_EXT_texture3D", F(EXT_texture3D) },
119 { OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) },
120 { ON, "GL_EXT_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
121 { OFF, "GL_EXT_texture_env_add", F(EXT_texture_env_add) },
122 { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) },
123 { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) },
124 { OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) },
125 { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) },
126 { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) },
127 { ON, "GL_EXT_texture_object", F(EXT_texture_object) },
128 { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) },
129 { OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) },
130 { OFF, "GL_EXT_texture_swizzle", F(EXT_texture_swizzle) },
131 { OFF, "GL_EXT_timer_query", F(EXT_timer_query) },
132 { ON, "GL_EXT_vertex_array", F(EXT_vertex_array) },
133 { OFF, "GL_EXT_vertex_array_bgra", F(EXT_vertex_array_bgra) },
134 { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) },
135 { OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) },
136 { OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) },
137 { ON, "GL_APPLE_packed_pixels", F(APPLE_packed_pixels) },
138 { OFF, "GL_APPLE_vertex_array_object", F(APPLE_vertex_array_object) },
139 { OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate) },
140 { OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)},
141 { OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)},
142 { OFF, "GL_ATI_fragment_shader", F(ATI_fragment_shader)},
143 { OFF, "GL_ATI_separate_stencil", F(ATI_separate_stencil)},
144 { ON, "GL_IBM_multimode_draw_arrays", F(IBM_multimode_draw_arrays) },
145 { ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) },
146 { OFF, "GL_IBM_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
147 { OFF, "GL_INGR_blend_func_separate", F(EXT_blend_func_separate) },
148 { OFF, "GL_MESA_pack_invert", F(MESA_pack_invert) },
149 { OFF, "GL_MESA_packed_depth_stencil", F(MESA_packed_depth_stencil) },
150 { OFF, "GL_MESA_program_debug", F(MESA_program_debug) },
151 { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) },
152 { OFF, "GL_MESA_texture_array", F(MESA_texture_array) },
153 { OFF, "GL_MESA_ycbcr_texture", F(MESA_ycbcr_texture) },
154 { ON, "GL_MESA_window_pos", F(ARB_window_pos) },
155 { OFF, "GL_NV_blend_square", F(NV_blend_square) },
156 { OFF, "GL_NV_fragment_program", F(NV_fragment_program) },
157 { ON, "GL_NV_light_max_exponent", F(NV_light_max_exponent) },
158 { OFF, "GL_NV_point_sprite", F(NV_point_sprite) },
159 { OFF, "GL_NV_texture_env_combine4", F(NV_texture_env_combine4) },
160 { OFF, "GL_NV_texture_rectangle", F(NV_texture_rectangle) },
161 { ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) },
162 { OFF, "GL_NV_vertex_program", F(NV_vertex_program) },
163 { OFF, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1) },
164 { ON, "GL_OES_read_format", F(OES_read_format) },
165 { OFF, "GL_SGI_color_matrix", F(SGI_color_matrix) },
166 { OFF, "GL_SGI_color_table", F(SGI_color_table) },
167 { OFF, "GL_SGI_texture_color_table", F(SGI_texture_color_table) },
168 { OFF, "GL_SGIS_generate_mipmap", F(SGIS_generate_mipmap) },
169 { OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) },
170 { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
171 { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) },
172 { ON, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) },
173 { OFF, "GL_S3_s3tc", F(S3_s3tc) },
174 };
175
176
177
178 /**
179 * Enable all extensions suitable for a software-only renderer.
180 * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc.
181 */
182 void
183 _mesa_enable_sw_extensions(GLcontext *ctx)
184 {
185 ctx->Extensions.ARB_depth_texture = GL_TRUE;
186 /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
187 #if FEATURE_ARB_fragment_program
188 ctx->Extensions.ARB_fragment_program = GL_TRUE;
189 ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE;
190 #endif
191 #if FEATURE_ARB_fragment_shader
192 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
193 #endif
194 #if FEATURE_ARB_framebuffer_object
195 ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
196 #endif
197 ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
198 ctx->Extensions.ARB_imaging = GL_TRUE;
199 ctx->Extensions.ARB_multitexture = GL_TRUE;
200 #if FEATURE_ARB_occlusion_query
201 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
202 #endif
203 ctx->Extensions.ARB_point_sprite = GL_TRUE;
204 #if FEATURE_ARB_shader_objects
205 ctx->Extensions.ARB_shader_objects = GL_TRUE;
206 #endif
207 #if FEATURE_ARB_shading_language_100
208 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
209 #endif
210 #if FEATURE_ARB_shading_language_120
211 ctx->Extensions.ARB_shading_language_120 = GL_FALSE; /* not quite done */
212 #endif
213 ctx->Extensions.ARB_shadow = GL_TRUE;
214 ctx->Extensions.ARB_shadow_ambient = GL_TRUE;
215 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
216 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
217 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
218 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
219 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
220 /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/
221 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
222 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
223 #if FEATURE_ARB_vertex_program
224 ctx->Extensions.ARB_vertex_program = GL_TRUE;
225 #endif
226 #if FEATURE_ARB_vertex_shader
227 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
228 #endif
229 #if FEATURE_ARB_vertex_buffer_object
230 /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
231 #endif
232 ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
233 #if FEATURE_ATI_fragment_shader
234 ctx->Extensions.ATI_fragment_shader = GL_TRUE;
235 #endif
236 ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
237 ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
238 ctx->Extensions.ATI_separate_stencil = GL_TRUE;
239 ctx->Extensions.EXT_blend_color = GL_TRUE;
240 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
241 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
242 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
243 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
244 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
245 ctx->Extensions.EXT_convolution = GL_TRUE;
246 ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
247 ctx->Extensions.EXT_fog_coord = GL_TRUE;
248 #if FEATURE_EXT_framebuffer_object
249 ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
250 #endif
251 #if FEATURE_EXT_framebuffer_blit
252 ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
253 #endif
254 ctx->Extensions.EXT_histogram = GL_TRUE;
255 /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
256 ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
257 ctx->Extensions.EXT_paletted_texture = GL_TRUE;
258 #if FEATURE_EXT_pixel_buffer_object
259 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
260 #endif
261 ctx->Extensions.EXT_point_parameters = GL_TRUE;
262 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
263 ctx->Extensions.EXT_secondary_color = GL_TRUE;
264 ctx->Extensions.EXT_shared_texture_palette = GL_TRUE;
265 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
266 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
267 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
268 ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
269 ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
270 ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
271 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
272 #if FEATURE_EXT_texture_sRGB
273 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
274 #endif
275 ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
276 ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
277 /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/
278 ctx->Extensions.MESA_pack_invert = GL_TRUE;
279 #if FEATURE_MESA_program_debug
280 ctx->Extensions.MESA_program_debug = GL_TRUE;
281 #endif
282 ctx->Extensions.MESA_resize_buffers = GL_TRUE;
283 ctx->Extensions.MESA_texture_array = GL_TRUE;
284 ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
285 ctx->Extensions.NV_blend_square = GL_TRUE;
286 /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/
287 ctx->Extensions.NV_point_sprite = GL_TRUE;
288 ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
289 ctx->Extensions.NV_texture_rectangle = GL_TRUE;
290 /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/
291 #if FEATURE_NV_vertex_program
292 ctx->Extensions.NV_vertex_program = GL_TRUE;
293 ctx->Extensions.NV_vertex_program1_1 = GL_TRUE;
294 #endif
295 #if FEATURE_NV_fragment_program
296 ctx->Extensions.NV_fragment_program = GL_TRUE;
297 #endif
298 ctx->Extensions.SGI_color_matrix = GL_TRUE;
299 ctx->Extensions.SGI_color_table = GL_TRUE;
300 ctx->Extensions.SGI_texture_color_table = GL_TRUE;
301 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
302 ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE;
303 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
304 ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE;
305 #endif
306 #if FEATURE_texture_fxt1
307 _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
308 #endif
309 #if FEATURE_texture_s3tc
310 if (ctx->Mesa_DXTn) {
311 _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
312 _mesa_enable_extension(ctx, "GL_S3_s3tc");
313 }
314 #endif
315 }
316
317
318 /**
319 * Enable GL_ARB_imaging and all the EXT extensions that are subsets of it.
320 */
321 void
322 _mesa_enable_imaging_extensions(GLcontext *ctx)
323 {
324 ctx->Extensions.ARB_imaging = GL_TRUE;
325 ctx->Extensions.EXT_blend_color = GL_TRUE;
326 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
327 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
328 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
329 ctx->Extensions.EXT_convolution = GL_TRUE;
330 ctx->Extensions.EXT_histogram = GL_TRUE;
331 ctx->Extensions.SGI_color_matrix = GL_TRUE;
332 ctx->Extensions.SGI_color_table = GL_TRUE;
333 }
334
335
336
337 /**
338 * Enable all OpenGL 1.3 features and extensions.
339 * A convenience function to be called by drivers.
340 */
341 void
342 _mesa_enable_1_3_extensions(GLcontext *ctx)
343 {
344 /*ctx->Extensions.ARB_multisample = GL_TRUE;*/
345 ctx->Extensions.ARB_multitexture = GL_TRUE;
346 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
347 /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/
348 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
349 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
350 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
351 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
352 /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/
353 }
354
355
356
357 /**
358 * Enable all OpenGL 1.4 features and extensions.
359 * A convenience function to be called by drivers.
360 */
361 void
362 _mesa_enable_1_4_extensions(GLcontext *ctx)
363 {
364 ctx->Extensions.ARB_depth_texture = GL_TRUE;
365 ctx->Extensions.ARB_shadow = GL_TRUE;
366 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
367 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
368 ctx->Extensions.ARB_window_pos = GL_TRUE;
369 ctx->Extensions.EXT_blend_color = GL_TRUE;
370 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
371 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
372 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
373 ctx->Extensions.EXT_fog_coord = GL_TRUE;
374 /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
375 ctx->Extensions.EXT_point_parameters = GL_TRUE;
376 ctx->Extensions.EXT_secondary_color = GL_TRUE;
377 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
378 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
379 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
380 }
381
382
383 /**
384 * Enable all OpenGL 1.5 features and extensions.
385 * A convenience function to be called by drivers.
386 */
387 void
388 _mesa_enable_1_5_extensions(GLcontext *ctx)
389 {
390 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
391 /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
392 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
393 }
394
395
396 /**
397 * Enable all OpenGL 2.0 features and extensions.
398 * A convenience function to be called by drivers.
399 */
400 void
401 _mesa_enable_2_0_extensions(GLcontext *ctx)
402 {
403 /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
404 #if FEATURE_ARB_fragment_shader
405 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
406 #endif
407 ctx->Extensions.ARB_point_sprite = GL_TRUE;
408 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
409 #if FEATURE_ARB_shader_objects
410 ctx->Extensions.ARB_shader_objects = GL_TRUE;
411 #endif
412 #if FEATURE_ARB_shading_language_100
413 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
414 #endif
415 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
416 #if FEATURE_ARB_vertex_shader
417 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
418 #endif
419 }
420
421
422 /**
423 * Enable all OpenGL 2.1 features and extensions.
424 * A convenience function to be called by drivers.
425 */
426 void
427 _mesa_enable_2_1_extensions(GLcontext *ctx)
428 {
429 #if FEATURE_EXT_pixel_buffer_object
430 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
431 #endif
432 #if FEATURE_EXT_texture_sRGB
433 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
434 #endif
435 #ifdef FEATURE_ARB_shading_language_120
436 ctx->Extensions.ARB_shading_language_120 = GL_FALSE; /* not quite done */
437 #endif
438 }
439
440
441
442 /**
443 * Either enable or disable the named extension.
444 */
445 static void
446 set_extension( GLcontext *ctx, const char *name, GLboolean state )
447 {
448 GLboolean *base = (GLboolean *) &ctx->Extensions;
449 GLuint i;
450
451 if (ctx->Extensions.String) {
452 /* The string was already queried - can't change it now! */
453 _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name);
454 return;
455 }
456
457 for (i = 0 ; i < Elements(default_extensions) ; i++) {
458 if (_mesa_strcmp(default_extensions[i].name, name) == 0) {
459 if (default_extensions[i].flag_offset) {
460 GLboolean *enabled = base + default_extensions[i].flag_offset;
461 *enabled = state;
462 }
463 return;
464 }
465 }
466 _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
467 }
468
469
470 /**
471 * Enable the named extension.
472 * Typically called by drivers.
473 */
474 void
475 _mesa_enable_extension( GLcontext *ctx, const char *name )
476 {
477 set_extension(ctx, name, GL_TRUE);
478 }
479
480
481 /**
482 * Disable the named extension.
483 * XXX is this really needed???
484 */
485 void
486 _mesa_disable_extension( GLcontext *ctx, const char *name )
487 {
488 set_extension(ctx, name, GL_FALSE);
489 }
490
491
492 /**
493 * Test if the named extension is enabled in this context.
494 */
495 GLboolean
496 _mesa_extension_is_enabled( GLcontext *ctx, const char *name )
497 {
498 const GLboolean *base = (const GLboolean *) &ctx->Extensions;
499 GLuint i;
500
501 for (i = 0 ; i < Elements(default_extensions) ; i++) {
502 if (_mesa_strcmp(default_extensions[i].name, name) == 0) {
503 if (!default_extensions[i].flag_offset)
504 return GL_TRUE;
505 return *(base + default_extensions[i].flag_offset);
506 }
507 }
508 return GL_FALSE;
509 }
510
511
512 /**
513 * Run through the default_extensions array above and set the
514 * ctx->Extensions.ARB/EXT_* flags accordingly.
515 * To be called during context initialization.
516 */
517 void
518 _mesa_init_extensions( GLcontext *ctx )
519 {
520 GLboolean *base = (GLboolean *) &ctx->Extensions;
521 GLuint i;
522
523 for (i = 0 ; i < Elements(default_extensions) ; i++) {
524 if (default_extensions[i].enabled &&
525 default_extensions[i].flag_offset) {
526 *(base + default_extensions[i].flag_offset) = GL_TRUE;
527 }
528 }
529 }
530
531
532 /**
533 * Construct the GL_EXTENSIONS string. Called the first time that
534 * glGetString(GL_EXTENSIONS) is called.
535 */
536 GLubyte *
537 _mesa_make_extension_string( GLcontext *ctx )
538 {
539 const GLboolean *base = (const GLboolean *) &ctx->Extensions;
540 GLuint extStrLen = 0;
541 GLubyte *s;
542 GLuint i;
543
544 /* first, compute length of the extension string */
545 for (i = 0 ; i < Elements(default_extensions) ; i++) {
546 if (!default_extensions[i].flag_offset ||
547 *(base + default_extensions[i].flag_offset)) {
548 extStrLen += (GLuint)_mesa_strlen(default_extensions[i].name) + 1;
549 }
550 }
551 s = (GLubyte *) _mesa_malloc(extStrLen);
552
553 /* second, build the extension string */
554 extStrLen = 0;
555 for (i = 0 ; i < Elements(default_extensions) ; i++) {
556 if (!default_extensions[i].flag_offset ||
557 *(base + default_extensions[i].flag_offset)) {
558 GLuint len = (GLuint)_mesa_strlen(default_extensions[i].name);
559 _mesa_memcpy(s + extStrLen, default_extensions[i].name, len);
560 extStrLen += len;
561 s[extStrLen] = (GLubyte) ' ';
562 extStrLen++;
563 }
564 }
565 ASSERT(extStrLen > 0);
566
567 s[extStrLen - 1] = 0;
568
569 return s;
570 }