Infrastructure for GL_ARB_seamless_cube_map
[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 "simple_list.h"
32 #include "mtypes.h"
33
34
35 #define F(x) offsetof(struct gl_extensions, x)
36 #define ON GL_TRUE
37 #define OFF GL_FALSE
38
39
40 /*
41 * Note: The GL_MESAX_* extensions are placeholders for future ARB extensions.
42 */
43 static const struct {
44 GLboolean enabled;
45 const char *name;
46 int flag_offset;
47 } default_extensions[] = {
48 { OFF, "GL_ARB_copy_buffer", F(ARB_copy_buffer) },
49 { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) },
50 { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) },
51 { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) },
52 { OFF, "GL_ARB_fragment_program_shadow", F(ARB_fragment_program_shadow) },
53 { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) },
54 { OFF, "GL_ARB_framebuffer_object", F(ARB_framebuffer_object) },
55 { OFF, "GL_ARB_half_float_pixel", F(ARB_half_float_pixel) },
56 { OFF, "GL_ARB_imaging", F(ARB_imaging) },
57 { OFF, "GL_ARB_map_buffer_range", F(ARB_map_buffer_range) },
58 { ON, "GL_ARB_multisample", F(ARB_multisample) },
59 { OFF, "GL_ARB_multitexture", F(ARB_multitexture) },
60 { OFF, "GL_ARB_occlusion_query", F(ARB_occlusion_query) },
61 { OFF, "GL_ARB_pixel_buffer_object", F(EXT_pixel_buffer_object) },
62 { OFF, "GL_ARB_point_parameters", F(EXT_point_parameters) },
63 { OFF, "GL_ARB_point_sprite", F(ARB_point_sprite) },
64 { OFF, "GL_ARB_seamless_cube_map", F(ARB_seamless_cube_map) },
65 { OFF, "GL_ARB_shader_objects", F(ARB_shader_objects) },
66 { OFF, "GL_ARB_shading_language_100", F(ARB_shading_language_100) },
67 { OFF, "GL_ARB_shading_language_120", F(ARB_shading_language_120) },
68 { OFF, "GL_ARB_shadow", F(ARB_shadow) },
69 { OFF, "GL_ARB_shadow_ambient", F(ARB_shadow_ambient) },
70 { OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) },
71 { ON, "GL_ARB_texture_compression", F(ARB_texture_compression) },
72 { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) },
73 { OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) },
74 { OFF, "GL_ARB_texture_env_combine", F(ARB_texture_env_combine) },
75 { OFF, "GL_ARB_texture_env_crossbar", F(ARB_texture_env_crossbar) },
76 { OFF, "GL_ARB_texture_env_dot3", F(ARB_texture_env_dot3) },
77 { OFF, "GL_MESAX_texture_float", F(ARB_texture_float) },
78 { OFF, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
79 { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)},
80 { OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) },
81 { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) },
82 { OFF, "GL_ARB_vertex_array_bgra", F(EXT_vertex_array_bgra) },
83 { OFF, "GL_ARB_vertex_array_object", F(ARB_vertex_array_object) },
84 { ON, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) },
85 { OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) },
86 { OFF, "GL_ARB_vertex_shader", F(ARB_vertex_shader) },
87 { ON, "GL_ARB_window_pos", F(ARB_window_pos) },
88 { ON, "GL_EXT_abgr", F(EXT_abgr) },
89 { ON, "GL_EXT_bgra", F(EXT_bgra) },
90 { OFF, "GL_EXT_blend_color", F(EXT_blend_color) },
91 { OFF, "GL_EXT_blend_equation_separate", F(EXT_blend_equation_separate) },
92 { OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) },
93 { OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) },
94 { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) },
95 { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) },
96 { OFF, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) },
97 { OFF, "GL_EXT_cull_vertex", F(EXT_cull_vertex) },
98 { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) },
99 { OFF, "GL_EXT_convolution", F(EXT_convolution) },
100 { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) },
101 { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) },
102 { ON, "GL_EXT_draw_range_elements", F(EXT_draw_range_elements) },
103 { OFF, "GL_EXT_framebuffer_object", F(EXT_framebuffer_object) },
104 { OFF, "GL_EXT_framebuffer_blit", F(EXT_framebuffer_blit) },
105 { OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) },
106 { OFF, "GL_EXT_gpu_program_parameters", F(EXT_gpu_program_parameters) },
107 { OFF, "GL_EXT_histogram", F(EXT_histogram) },
108 { ON, "GL_EXT_multi_draw_arrays", F(EXT_multi_draw_arrays) },
109 { OFF, "GL_EXT_packed_depth_stencil", F(EXT_packed_depth_stencil) },
110 { ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) },
111 { OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) },
112 { OFF, "GL_EXT_pixel_buffer_object", F(EXT_pixel_buffer_object) },
113 { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) },
114 { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) },
115 { OFF, "GL_EXT_provoking_vertex", F(EXT_provoking_vertex) },
116 { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) },
117 { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) },
118 { ON, "GL_EXT_separate_specular_color", F(EXT_separate_specular_color) },
119 { OFF, "GL_EXT_shadow_funcs", F(EXT_shadow_funcs) },
120 { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) },
121 { OFF, "GL_EXT_stencil_two_side", F(EXT_stencil_two_side) },
122 { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) },
123 { ON, "GL_EXT_subtexture", F(EXT_subtexture) },
124 { ON, "GL_EXT_texture", F(EXT_texture) },
125 { ON, "GL_EXT_texture3D", F(EXT_texture3D) },
126 { OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) },
127 { ON, "GL_EXT_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
128 { OFF, "GL_EXT_texture_env_add", F(EXT_texture_env_add) },
129 { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) },
130 { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) },
131 { OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) },
132 { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) },
133 { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) },
134 { ON, "GL_EXT_texture_object", F(EXT_texture_object) },
135 { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) },
136 { OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) },
137 { OFF, "GL_EXT_texture_swizzle", F(EXT_texture_swizzle) },
138 { OFF, "GL_EXT_timer_query", F(EXT_timer_query) },
139 { ON, "GL_EXT_vertex_array", F(EXT_vertex_array) },
140 { OFF, "GL_EXT_vertex_array_bgra", F(EXT_vertex_array_bgra) },
141 { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) },
142 { OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) },
143 { OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) },
144 { ON, "GL_APPLE_packed_pixels", F(APPLE_packed_pixels) },
145 { OFF, "GL_APPLE_vertex_array_object", F(APPLE_vertex_array_object) },
146 { OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate) },
147 { OFF, "GL_ATI_envmap_bumpmap", F(ATI_envmap_bumpmap) },
148 { OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)},
149 { OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)},
150 { OFF, "GL_ATI_fragment_shader", F(ATI_fragment_shader)},
151 { OFF, "GL_ATI_separate_stencil", F(ATI_separate_stencil)},
152 { ON, "GL_IBM_multimode_draw_arrays", F(IBM_multimode_draw_arrays) },
153 { ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) },
154 { OFF, "GL_IBM_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
155 { OFF, "GL_INGR_blend_func_separate", F(EXT_blend_func_separate) },
156 { OFF, "GL_MESA_pack_invert", F(MESA_pack_invert) },
157 { OFF, "GL_MESA_packed_depth_stencil", F(MESA_packed_depth_stencil) },
158 { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) },
159 { OFF, "GL_MESA_texture_array", F(MESA_texture_array) },
160 { OFF, "GL_MESA_texture_signed_rgba", F(MESA_texture_signed_rgba) },
161 { OFF, "GL_MESA_ycbcr_texture", F(MESA_ycbcr_texture) },
162 { ON, "GL_MESA_window_pos", F(ARB_window_pos) },
163 { OFF, "GL_NV_blend_square", F(NV_blend_square) },
164 { OFF, "GL_NV_fragment_program", F(NV_fragment_program) },
165 { ON, "GL_NV_light_max_exponent", F(NV_light_max_exponent) },
166 { OFF, "GL_NV_point_sprite", F(NV_point_sprite) },
167 { OFF, "GL_NV_texture_env_combine4", F(NV_texture_env_combine4) },
168 { OFF, "GL_NV_texture_rectangle", F(NV_texture_rectangle) },
169 { ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) },
170 { OFF, "GL_NV_vertex_program", F(NV_vertex_program) },
171 { OFF, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1) },
172 { ON, "GL_OES_read_format", F(OES_read_format) },
173 { OFF, "GL_SGI_color_matrix", F(SGI_color_matrix) },
174 { OFF, "GL_SGI_color_table", F(SGI_color_table) },
175 { OFF, "GL_SGI_texture_color_table", F(SGI_texture_color_table) },
176 { OFF, "GL_SGIS_generate_mipmap", F(SGIS_generate_mipmap) },
177 { OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) },
178 { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
179 { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) },
180 { ON, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) },
181 { OFF, "GL_S3_s3tc", F(S3_s3tc) },
182 };
183
184
185
186 /**
187 * Enable all extensions suitable for a software-only renderer.
188 * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc.
189 */
190 void
191 _mesa_enable_sw_extensions(GLcontext *ctx)
192 {
193 ctx->Extensions.ARB_copy_buffer = GL_TRUE;
194 ctx->Extensions.ARB_depth_texture = GL_TRUE;
195 /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
196 #if FEATURE_ARB_fragment_program
197 ctx->Extensions.ARB_fragment_program = GL_TRUE;
198 ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE;
199 #endif
200 #if FEATURE_ARB_fragment_shader
201 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
202 #endif
203 #if FEATURE_ARB_framebuffer_object
204 ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
205 #endif
206 ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
207 ctx->Extensions.ARB_imaging = GL_TRUE;
208 ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
209 ctx->Extensions.ARB_multitexture = GL_TRUE;
210 #if FEATURE_ARB_occlusion_query
211 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
212 #endif
213 ctx->Extensions.ARB_point_sprite = GL_TRUE;
214 #if FEATURE_ARB_shader_objects
215 ctx->Extensions.ARB_shader_objects = GL_TRUE;
216 #endif
217 #if FEATURE_ARB_shading_language_100
218 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
219 #endif
220 #if FEATURE_ARB_shading_language_120
221 ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
222 #endif
223 ctx->Extensions.ARB_shadow = GL_TRUE;
224 ctx->Extensions.ARB_shadow_ambient = GL_TRUE;
225 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
226 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
227 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
228 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
229 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
230 /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/
231 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
232 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
233 ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
234 #if FEATURE_ARB_vertex_program
235 ctx->Extensions.ARB_vertex_program = GL_TRUE;
236 #endif
237 #if FEATURE_ARB_vertex_shader
238 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
239 #endif
240 #if FEATURE_ARB_vertex_buffer_object
241 /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
242 #endif
243 ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
244 ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE;
245 #if FEATURE_ATI_fragment_shader
246 ctx->Extensions.ATI_fragment_shader = GL_TRUE;
247 #endif
248 ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
249 ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
250 ctx->Extensions.ATI_separate_stencil = GL_TRUE;
251 ctx->Extensions.EXT_blend_color = GL_TRUE;
252 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
253 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
254 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
255 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
256 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
257 ctx->Extensions.EXT_convolution = GL_TRUE;
258 ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
259 ctx->Extensions.EXT_fog_coord = GL_TRUE;
260 #if FEATURE_EXT_framebuffer_object
261 ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
262 #endif
263 #if FEATURE_EXT_framebuffer_blit
264 ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
265 #endif
266 ctx->Extensions.EXT_histogram = GL_TRUE;
267 /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
268 ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
269 ctx->Extensions.EXT_paletted_texture = GL_TRUE;
270 #if FEATURE_EXT_pixel_buffer_object
271 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
272 #endif
273 ctx->Extensions.EXT_point_parameters = GL_TRUE;
274 ctx->Extensions.EXT_provoking_vertex = GL_TRUE;
275 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
276 ctx->Extensions.EXT_secondary_color = GL_TRUE;
277 ctx->Extensions.EXT_shared_texture_palette = GL_TRUE;
278 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
279 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
280 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
281 ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
282 ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
283 ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
284 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
285 #if FEATURE_EXT_texture_sRGB
286 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
287 #endif
288 ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
289 ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
290 /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/
291 ctx->Extensions.MESA_pack_invert = GL_TRUE;
292 ctx->Extensions.MESA_resize_buffers = GL_TRUE;
293 ctx->Extensions.MESA_texture_array = GL_TRUE;
294 ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
295 ctx->Extensions.NV_blend_square = GL_TRUE;
296 /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/
297 ctx->Extensions.NV_point_sprite = GL_TRUE;
298 ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
299 ctx->Extensions.NV_texture_rectangle = GL_TRUE;
300 /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/
301 #if FEATURE_NV_vertex_program
302 ctx->Extensions.NV_vertex_program = GL_TRUE;
303 ctx->Extensions.NV_vertex_program1_1 = GL_TRUE;
304 #endif
305 #if FEATURE_NV_fragment_program
306 ctx->Extensions.NV_fragment_program = GL_TRUE;
307 #endif
308 ctx->Extensions.SGI_color_matrix = GL_TRUE;
309 ctx->Extensions.SGI_color_table = GL_TRUE;
310 ctx->Extensions.SGI_texture_color_table = GL_TRUE;
311 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
312 ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE;
313 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
314 ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE;
315 #endif
316 #if FEATURE_texture_fxt1
317 _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
318 #endif
319 #if FEATURE_texture_s3tc
320 if (ctx->Mesa_DXTn) {
321 _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
322 _mesa_enable_extension(ctx, "GL_S3_s3tc");
323 }
324 #endif
325 }
326
327
328 /**
329 * Enable GL_ARB_imaging and all the EXT extensions that are subsets of it.
330 */
331 void
332 _mesa_enable_imaging_extensions(GLcontext *ctx)
333 {
334 ctx->Extensions.ARB_imaging = GL_TRUE;
335 ctx->Extensions.EXT_blend_color = GL_TRUE;
336 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
337 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
338 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
339 ctx->Extensions.EXT_convolution = GL_TRUE;
340 ctx->Extensions.EXT_histogram = GL_TRUE;
341 ctx->Extensions.SGI_color_matrix = GL_TRUE;
342 ctx->Extensions.SGI_color_table = GL_TRUE;
343 }
344
345
346
347 /**
348 * Enable all OpenGL 1.3 features and extensions.
349 * A convenience function to be called by drivers.
350 */
351 void
352 _mesa_enable_1_3_extensions(GLcontext *ctx)
353 {
354 /*ctx->Extensions.ARB_multisample = GL_TRUE;*/
355 ctx->Extensions.ARB_multitexture = GL_TRUE;
356 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
357 /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/
358 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
359 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
360 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
361 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
362 /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/
363 }
364
365
366
367 /**
368 * Enable all OpenGL 1.4 features and extensions.
369 * A convenience function to be called by drivers.
370 */
371 void
372 _mesa_enable_1_4_extensions(GLcontext *ctx)
373 {
374 ctx->Extensions.ARB_depth_texture = GL_TRUE;
375 ctx->Extensions.ARB_shadow = GL_TRUE;
376 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
377 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
378 ctx->Extensions.ARB_window_pos = GL_TRUE;
379 ctx->Extensions.EXT_blend_color = GL_TRUE;
380 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
381 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
382 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
383 ctx->Extensions.EXT_fog_coord = GL_TRUE;
384 /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
385 ctx->Extensions.EXT_point_parameters = GL_TRUE;
386 ctx->Extensions.EXT_secondary_color = GL_TRUE;
387 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
388 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
389 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
390 }
391
392
393 /**
394 * Enable all OpenGL 1.5 features and extensions.
395 * A convenience function to be called by drivers.
396 */
397 void
398 _mesa_enable_1_5_extensions(GLcontext *ctx)
399 {
400 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
401 /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
402 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
403 }
404
405
406 /**
407 * Enable all OpenGL 2.0 features and extensions.
408 * A convenience function to be called by drivers.
409 */
410 void
411 _mesa_enable_2_0_extensions(GLcontext *ctx)
412 {
413 /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
414 #if FEATURE_ARB_fragment_shader
415 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
416 #endif
417 ctx->Extensions.ARB_point_sprite = GL_TRUE;
418 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
419 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
420 #if FEATURE_ARB_shader_objects
421 ctx->Extensions.ARB_shader_objects = GL_TRUE;
422 #endif
423 #if FEATURE_ARB_shading_language_100
424 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
425 #endif
426 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
427 #if FEATURE_ARB_vertex_shader
428 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
429 #endif
430 }
431
432
433 /**
434 * Enable all OpenGL 2.1 features and extensions.
435 * A convenience function to be called by drivers.
436 */
437 void
438 _mesa_enable_2_1_extensions(GLcontext *ctx)
439 {
440 #if FEATURE_EXT_pixel_buffer_object
441 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
442 #endif
443 #if FEATURE_EXT_texture_sRGB
444 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
445 #endif
446 #ifdef FEATURE_ARB_shading_language_120
447 ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
448 #endif
449 }
450
451
452
453 /**
454 * Either enable or disable the named extension.
455 * \return GL_TRUE for success, GL_FALSE if invalid extension name
456 */
457 static GLboolean
458 set_extension( GLcontext *ctx, const char *name, GLboolean state )
459 {
460 GLboolean *base = (GLboolean *) &ctx->Extensions;
461 GLuint i;
462
463 if (ctx->Extensions.String) {
464 /* The string was already queried - can't change it now! */
465 _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name);
466 return GL_FALSE;
467 }
468
469 for (i = 0 ; i < Elements(default_extensions) ; i++) {
470 if (_mesa_strcmp(default_extensions[i].name, name) == 0) {
471 if (default_extensions[i].flag_offset) {
472 GLboolean *enabled = base + default_extensions[i].flag_offset;
473 *enabled = state;
474 }
475 return GL_TRUE;
476 }
477 }
478 return GL_FALSE;
479 }
480
481
482 /**
483 * Enable the named extension.
484 * Typically called by drivers.
485 */
486 void
487 _mesa_enable_extension( GLcontext *ctx, const char *name )
488 {
489 if (!set_extension(ctx, name, GL_TRUE))
490 _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
491 }
492
493
494 /**
495 * Disable the named extension.
496 * XXX is this really needed???
497 */
498 void
499 _mesa_disable_extension( GLcontext *ctx, const char *name )
500 {
501 if (!set_extension(ctx, name, GL_FALSE))
502 _mesa_problem(ctx, "Trying to disable unknown extension: %s", name);
503 }
504
505
506 /**
507 * Test if the named extension is enabled in this context.
508 */
509 GLboolean
510 _mesa_extension_is_enabled( GLcontext *ctx, const char *name )
511 {
512 const GLboolean *base = (const GLboolean *) &ctx->Extensions;
513 GLuint i;
514
515 for (i = 0 ; i < Elements(default_extensions) ; i++) {
516 if (_mesa_strcmp(default_extensions[i].name, name) == 0) {
517 if (!default_extensions[i].flag_offset)
518 return GL_TRUE;
519 return *(base + default_extensions[i].flag_offset);
520 }
521 }
522 return GL_FALSE;
523 }
524
525
526 /**
527 * Append string 'b' onto string 'a'. Free 'a' and return new string.
528 */
529 static char *
530 append(const char *a, const char *b)
531 {
532 const GLuint aLen = a ? _mesa_strlen(a) : 0;
533 const GLuint bLen = b ? _mesa_strlen(b) : 0;
534 char *s = _mesa_calloc(aLen + bLen + 1);
535 if (s) {
536 if (a)
537 _mesa_memcpy(s, a, aLen);
538 if (b)
539 _mesa_memcpy(s + aLen, b, bLen);
540 s[aLen + bLen] = '\0';
541 }
542 if (a)
543 _mesa_free((void *) a);
544 return s;
545 }
546
547
548 /**
549 * Check the MESA_EXTENSION_OVERRIDE env var.
550 * For extension names that are recognized, turn them on. For extension
551 * names that are recognized and prefixed with '-', turn them off.
552 * Return a string of the unknown/leftover names.
553 */
554 static const char *
555 get_extension_override( GLcontext *ctx )
556 {
557 const char *envExt = _mesa_getenv("MESA_EXTENSION_OVERRIDE");
558 char *extraExt = NULL;
559 char ext[1000];
560 GLuint extLen = 0;
561 GLuint i;
562 GLboolean disableExt = GL_FALSE;
563
564 if (!envExt)
565 return NULL;
566
567 for (i = 0; ; i++) {
568 if (envExt[i] == '\0' || envExt[i] == ' ') {
569 /* terminate/process 'ext' if extLen > 0 */
570 if (extLen > 0) {
571 assert(extLen < sizeof(ext));
572 /* enable extension named by 'ext' */
573 ext[extLen] = 0;
574 if (!set_extension(ctx, ext, !disableExt)) {
575 /* unknown extension name, append it to extraExt */
576 if (extraExt) {
577 extraExt = append(extraExt, " ");
578 }
579 extraExt = append(extraExt, ext);
580 }
581 extLen = 0;
582 disableExt = GL_FALSE;
583 }
584 if (envExt[i] == '\0')
585 break;
586 }
587 else if (envExt[i] == '-') {
588 disableExt = GL_TRUE;
589 }
590 else {
591 /* accumulate this non-space character */
592 ext[extLen++] = envExt[i];
593 }
594 }
595
596 return extraExt;
597 }
598
599
600 /**
601 * Run through the default_extensions array above and set the
602 * ctx->Extensions.ARB/EXT_* flags accordingly.
603 * To be called during context initialization.
604 */
605 void
606 _mesa_init_extensions( GLcontext *ctx )
607 {
608 GLboolean *base = (GLboolean *) &ctx->Extensions;
609 GLuint i;
610
611 for (i = 0 ; i < Elements(default_extensions) ; i++) {
612 if (default_extensions[i].enabled &&
613 default_extensions[i].flag_offset) {
614 *(base + default_extensions[i].flag_offset) = GL_TRUE;
615 }
616 }
617 }
618
619
620 /**
621 * Construct the GL_EXTENSIONS string. Called the first time that
622 * glGetString(GL_EXTENSIONS) is called.
623 */
624 GLubyte *
625 _mesa_make_extension_string( GLcontext *ctx )
626 {
627 const GLboolean *base = (const GLboolean *) &ctx->Extensions;
628 const char *extraExt = get_extension_override(ctx);
629 GLuint extStrLen = 0;
630 char *s;
631 GLuint i;
632
633 /* first, compute length of the extension string */
634 for (i = 0 ; i < Elements(default_extensions) ; i++) {
635 if (!default_extensions[i].flag_offset ||
636 *(base + default_extensions[i].flag_offset)) {
637 extStrLen += (GLuint)_mesa_strlen(default_extensions[i].name) + 1;
638 }
639 }
640
641 if (extraExt)
642 extStrLen += _mesa_strlen(extraExt) + 1; /* +1 for space */
643
644 /* allocate the extension string */
645 s = (char *) _mesa_malloc(extStrLen);
646 if (!s)
647 return NULL;
648
649 /* second, build the extension string */
650 extStrLen = 0;
651 for (i = 0 ; i < Elements(default_extensions) ; i++) {
652 if (!default_extensions[i].flag_offset ||
653 *(base + default_extensions[i].flag_offset)) {
654 GLuint len = (GLuint)_mesa_strlen(default_extensions[i].name);
655 _mesa_memcpy(s + extStrLen, default_extensions[i].name, len);
656 extStrLen += len;
657 s[extStrLen] = ' ';
658 extStrLen++;
659 }
660 }
661 ASSERT(extStrLen > 0);
662
663 s[extStrLen - 1] = 0; /* -1 to overwrite trailing the ' ' */
664
665 if (extraExt) {
666 s = append(s, " ");
667 s = append(s, extraExt);
668 }
669
670 return (GLubyte *) s;
671 }