1 /* $Id: extensions.c,v 1.72 2002/04/02 16:15:17 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 #include "extensions.h"
35 #include "simple_list.h"
40 #define MAX_EXT_NAMELEN 80
43 struct extension
*next
, *prev
;
45 GLboolean
*flag
; /* optional flag stored elsewhere */
46 char name
[MAX_EXT_NAMELEN
+1];
47 void (*notify
)( GLcontext
*, GLboolean
);
50 #define F(x) (int)&(((struct gl_extensions *)0)->x)
58 } default_extensions
[] = {
59 { OFF
, "GL_ARB_depth_texture", F(ARB_depth_texture
) },
60 { OFF
, "GL_ARB_imaging", F(ARB_imaging
) },
61 { OFF
, "GL_ARB_multisample", F(ARB_multisample
) },
62 { OFF
, "GL_ARB_multitexture", F(ARB_multitexture
) },
63 { OFF
, "GL_ARB_point_parameters", F(EXT_point_parameters
) },
64 { OFF
, "GL_ARB_shadow", F(ARB_shadow
) },
65 { OFF
, "GL_ARB_shadow_ambient", F(SGIX_shadow_ambient
) },
66 { OFF
, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp
) },
67 { OFF
, "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_dot3", F(ARB_texture_env_dot3
) },
72 { OFF
, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat
)},
73 { ON
, "GL_ARB_transpose_matrix", 0 },
74 { ON
, "GL_ARB_window_pos", F(ARB_window_pos
) },
75 { ON
, "GL_EXT_abgr", 0 },
76 { ON
, "GL_EXT_bgra", 0 },
77 { OFF
, "GL_EXT_blend_color", F(EXT_blend_color
) },
78 { OFF
, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate
) },
79 { OFF
, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op
) },
80 { OFF
, "GL_EXT_blend_minmax", F(EXT_blend_minmax
) },
81 { OFF
, "GL_EXT_blend_subtract", F(EXT_blend_subtract
) },
82 { ON
, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint
) },
83 { OFF
, "GL_EXT_cull_vertex", 0 },
84 { OFF
, "GL_EXT_convolution", F(EXT_convolution
) },
85 { ON
, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array
) },
86 { OFF
, "GL_EXT_fog_coord", F(EXT_fog_coord
) },
87 { OFF
, "GL_EXT_histogram", F(EXT_histogram
) },
88 { ON
, "GL_EXT_packed_pixels", F(EXT_packed_pixels
) },
89 { OFF
, "GL_EXT_paletted_texture", F(EXT_paletted_texture
) },
90 { OFF
, "GL_EXT_point_parameters", F(EXT_point_parameters
) },
91 { ON
, "GL_EXT_polygon_offset", F(EXT_polygon_offset
) },
92 { ON
, "GL_EXT_rescale_normal", F(EXT_rescale_normal
) },
93 { OFF
, "GL_EXT_secondary_color", F(EXT_secondary_color
) },
94 { OFF
, "GL_EXT_shadow_funcs", F(EXT_shadow_funcs
) },
95 { OFF
, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette
) },
96 { OFF
, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap
) },
97 { ON
, "GL_EXT_texture3D", F(EXT_texture3D
) },
98 { OFF
, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc
) },
99 { OFF
, "GL_EXT_texture_edge_clamp", F(SGIS_texture_edge_clamp
) },
100 { OFF
, "GL_EXT_texture_env_add", F(EXT_texture_env_add
) },
101 { OFF
, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine
) },
102 { OFF
, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3
) },
103 { OFF
, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic
) },
104 { ON
, "GL_EXT_texture_object", F(EXT_texture_object
) },
105 { OFF
, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias
) },
106 { ON
, "GL_EXT_vertex_array", 0 },
107 { OFF
, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set
) },
108 { OFF
, "GL_HP_occlusion_test", F(HP_occlusion_test
) },
109 { ON
, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip
) },
110 { OFF
, "GL_INGR_blend_func_separate", F(INGR_blend_func_separate
) },
111 { OFF
, "GL_MESA_packed_depth_stencil", 0 },
112 { OFF
, "GL_MESA_resize_buffers", F(MESA_resize_buffers
) },
113 { OFF
, "GL_MESA_sprite_point", F(MESA_sprite_point
) },
114 { ON
, "GL_MESA_window_pos", F(MESA_window_pos
) },
115 { OFF
, "GL_NV_blend_square", F(NV_blend_square
) },
116 { ON
, "GL_NV_texgen_reflection", F(NV_texgen_reflection
) },
117 { OFF
, "GL_NV_vertex_program", F(NV_vertex_program
) },
118 { OFF
, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1
) },
119 { OFF
, "GL_SGI_color_matrix", F(SGI_color_matrix
) },
120 { OFF
, "GL_SGI_color_table", F(SGI_color_table
) },
121 { OFF
, "GL_SGIS_generate_mipmap", F(SGIS_generate_mipmap
) },
122 { OFF
, "GL_SGIS_pixel_texture", F(SGIS_pixel_texture
) },
123 { OFF
, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp
) },
124 { OFF
, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp
) },
125 { OFF
, "GL_SGIX_depth_texture", F(SGIX_depth_texture
) },
126 { OFF
, "GL_SGIX_pixel_texture", F(SGIX_pixel_texture
) },
127 { OFF
, "GL_SGIX_shadow", F(SGIX_shadow
) },
128 { OFF
, "GL_SGIX_shadow_ambient", F(SGIX_shadow_ambient
) },
129 { OFF
, "GL_3DFX_texture_compression_FXT1", F(_3DFX_texture_compression_FXT1
) }
136 * Enable all extensions suitable for a software-only renderer.
137 * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc.
140 _mesa_enable_sw_extensions(GLcontext
*ctx
)
142 const char *extensions
[] = {
143 "GL_ARB_depth_texture",
145 "GL_ARB_multitexture",
146 "GL_ARB_point_parameters",
148 "GL_ARB_shadow_ambient",
149 "GL_ARB_texture_border_clamp",
150 "GL_ARB_texture_cube_map",
151 "GL_ARB_texture_env_add",
152 "GL_ARB_texture_env_combine",
153 "GL_ARB_texture_env_dot3",
154 "GL_ARB_texture_mirrored_repeat",
155 "GL_EXT_blend_color",
156 "GL_EXT_blend_func_separate",
157 "GL_EXT_blend_logic_op",
158 "GL_EXT_blend_minmax",
159 "GL_EXT_blend_subtract",
160 "GL_EXT_convolution",
163 "GL_EXT_paletted_texture",
164 "GL_EXT_point_parameters",
165 "GL_EXT_shadow_funcs",
166 "GL_EXT_secondary_color",
167 "GL_EXT_shared_texture_palette",
168 "GL_EXT_stencil_wrap",
169 "GL_EXT_texture_edge_clamp",
170 "GL_EXT_texture_env_add",
171 "GL_EXT_texture_env_combine",
172 "GL_EXT_texture_env_dot3",
173 "GL_EXT_texture_lod_bias",
174 "GL_HP_occlusion_test",
175 "GL_INGR_blend_func_separate",
176 "GL_MESA_resize_buffers",
177 "GL_NV_blend_square",
178 "GL_NV_texgen_reflection",
179 "GL_NV_vertex_program",
180 "GL_NV_vertex_program1_1",
181 "GL_SGI_color_matrix",
182 "GL_SGI_color_table",
183 "GL_SGIS_generate_mipmap",
184 "GL_SGIS_pixel_texture",
185 "GL_SGIS_texture_edge_clamp",
186 "GL_SGIS_texture_border_clamp",
187 "GL_SGIX_depth_texture",
188 "GL_SGIX_pixel_texture",
190 "GL_SGIX_shadow_ambient",
195 for (i
= 0; extensions
[i
]; i
++) {
196 _mesa_enable_extension(ctx
, extensions
[i
]);
202 * Enable GL_ARB_imaging and all the EXT extensions that are subsets of it.
205 _mesa_enable_imaging_extensions(GLcontext
*ctx
)
207 const char *extensions
[] = {
209 "GL_EXT_blend_color",
210 "GL_EXT_blend_minmax",
211 "GL_EXT_blend_subtract",
212 "GL_EXT_convolution",
214 "GL_SGI_color_matrix",
215 "GL_SGI_color_table",
220 for (i
= 0; extensions
[i
]; i
++) {
221 _mesa_enable_extension(ctx
, extensions
[i
]);
228 * Enable all OpenGL 1.3 features and extensions.
231 _mesa_enable_1_3_extensions(GLcontext
*ctx
)
233 const char *extensions
[] = {
234 "GL_ARB_multisample",
235 "GL_ARB_multitexture",
236 "GL_ARB_texture_border_clamp",
237 "GL_ARB_texture_compression",
238 "GL_ARB_texture_cube_map",
239 "GL_ARB_texture_env_add",
240 "GL_ARB_texture_env_combine",
241 "GL_ARB_texture_env_dot3",
242 "GL_ARB_transpose_matrix",
247 for (i
= 0; extensions
[i
]; i
++) {
248 _mesa_enable_extension(ctx
, extensions
[i
]);
255 * Add a new extenstion. This would be called from a Mesa driver.
258 _mesa_add_extension( GLcontext
*ctx
,
261 GLboolean
*flag_ptr
)
263 /* We should never try to add an extension after
264 * _mesa_extensions_get_string() has been called!
266 assert(ctx
->Extensions
.ext_string
== 0);
269 struct extension
*t
= MALLOC_STRUCT(extension
);
270 t
->enabled
= enabled
;
271 strncpy(t
->name
, name
, MAX_EXT_NAMELEN
);
272 t
->name
[MAX_EXT_NAMELEN
] = 0;
276 insert_at_tail( ctx
->Extensions
.ext_list
, t
);
282 * Either enable or disable the named extension.
285 set_extension( GLcontext
*ctx
, const char *name
, GLint state
)
287 /* XXX we should assert that ext_string is null. We should never be
288 * enabling/disabling extensions after _mesa_extensions_get_string()
292 foreach( i
, ctx
->Extensions
.ext_list
)
293 if (strncmp(i
->name
, name
, MAX_EXT_NAMELEN
) == 0)
296 if (i
== ctx
->Extensions
.ext_list
) {
297 /* this is an error. Drivers should never try to enable/disable
298 * an extension which is unknown to Mesa or wasn't added by calling
299 * _mesa_add_extension().
312 _mesa_enable_extension( GLcontext
*ctx
, const char *name
)
314 if (ctx
->Extensions
.ext_string
== 0)
315 set_extension( ctx
, name
, 1 );
320 _mesa_disable_extension( GLcontext
*ctx
, const char *name
)
322 if (ctx
->Extensions
.ext_string
== 0)
323 set_extension( ctx
, name
, 0 );
328 * Test if the named extension is enabled in this context.
331 _mesa_extension_is_enabled( GLcontext
*ctx
, const char *name
)
334 foreach( i
, ctx
->Extensions
.ext_list
)
335 if (strncmp(i
->name
, name
, MAX_EXT_NAMELEN
) == 0) {
347 _mesa_extensions_dtr( GLcontext
*ctx
)
349 struct extension
*i
, *nexti
;
351 if (ctx
->Extensions
.ext_string
) {
352 FREE( ctx
->Extensions
.ext_string
);
353 ctx
->Extensions
.ext_string
= 0;
356 if (ctx
->Extensions
.ext_list
) {
357 foreach_s( i
, nexti
, ctx
->Extensions
.ext_list
) {
358 remove_from_list( i
);
362 FREE(ctx
->Extensions
.ext_list
);
363 ctx
->Extensions
.ext_list
= 0;
369 _mesa_extensions_ctr( GLcontext
*ctx
)
372 GLboolean
*base
= (GLboolean
*)&ctx
->Extensions
;
374 ctx
->Extensions
.ext_string
= NULL
;
375 ctx
->Extensions
.ext_list
= MALLOC_STRUCT(extension
);
376 make_empty_list( ctx
->Extensions
.ext_list
);
378 for (i
= 0 ; i
< Elements(default_extensions
) ; i
++) {
379 GLboolean
*ptr
= NULL
;
381 if (default_extensions
[i
].flag_offset
)
382 ptr
= base
+ default_extensions
[i
].flag_offset
;
384 (void) _mesa_add_extension( ctx
,
385 default_extensions
[i
].enabled
,
386 default_extensions
[i
].name
,
393 _mesa_extensions_get_string( GLcontext
*ctx
)
395 if (ctx
->Extensions
.ext_string
== 0)
400 foreach (i
, ctx
->Extensions
.ext_list
)
402 len
+= strlen(i
->name
) + 1;
407 str
= (char *)MALLOC(len
* sizeof(char));
408 ctx
->Extensions
.ext_string
= str
;
410 foreach (i
, ctx
->Extensions
.ext_list
)
412 strcpy(str
, i
->name
);
420 return ctx
->Extensions
.ext_string
;