1 /* $Id: extensions.c,v 1.39 2000/10/30 13:32:00 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 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 { ON
, "GL_ARB_imaging", F(ARB_imaging
) },
60 { ON
, "GL_ARB_multitexture", F(ARB_multitexture
) },
61 { OFF
, "GL_ARB_texture_compression", F(ARB_texture_compression
) },
62 { OFF
, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map
) },
63 { ON
, "GL_ARB_texture_env_add", F(ARB_texture_env_add
) },
64 { ON
, "GL_ARB_tranpose_matrix", 0 },
65 { ON
, "GL_EXT_abgr", 0 },
66 { OFF
, "GL_EXT_bgra", 0 },
67 { ON
, "GL_EXT_blend_color", F(EXT_blend_color
) },
68 { ON
, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate
) },
69 { ON
, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op
) },
70 { ON
, "GL_EXT_blend_minmax", F(EXT_blend_minmax
) },
71 { ON
, "GL_EXT_blend_subtract", F(EXT_blend_subtract
) },
72 { ON
, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint
) },
73 { OFF
, "GL_EXT_cull_vertex", 0 },
74 { ON
, "GL_EXT_convolution", F(EXT_convolution
) },
75 { ON
, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array
) },
76 { ON
, "GL_EXT_fog_coord", F(EXT_fog_coord
) },
77 { ON
, "GL_EXT_histogram", F(EXT_histogram
) },
78 { ON
, "GL_EXT_packed_pixels", F(EXT_packed_pixels
) },
79 { ON
, "GL_EXT_paletted_texture", F(EXT_paletted_texture
) },
80 { ON
, "GL_EXT_point_parameters", F(EXT_point_parameters
) },
81 { ON
, "GL_EXT_polygon_offset", F(EXT_polygon_offset
) },
82 { ON
, "GL_EXT_rescale_normal", F(EXT_rescale_normal
) },
83 { ON
, "GL_EXT_secondary_color", F(EXT_secondary_color
) },
84 { ON
, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette
) },
85 { ON
, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap
) },
86 { ON
, "GL_EXT_texture3D", F(EXT_texture3D
) },
87 { OFF
, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc
) },
88 { ON
, "GL_EXT_texture_env_add", F(EXT_texture_env_add
) },
89 { OFF
, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine
) },
90 { ON
, "GL_EXT_texture_object", F(EXT_texture_object
) },
91 { ON
, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias
) },
92 { ON
, "GL_EXT_vertex_array", 0 },
93 { OFF
, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set
) },
94 { OFF
, "GL_HP_occlusion_test", F(HP_occlusion_test
) },
95 { ON
, "GL_INGR_blend_func_separate", F(INGR_blend_func_separate
) },
96 { ON
, "GL_MESA_window_pos", F(MESA_window_pos
) },
97 { ON
, "GL_MESA_resize_buffers", F(MESA_resize_buffers
) },
98 { OFF
, "GL_NV_blend_square", F(NV_blend_square
) },
99 { ON
, "GL_NV_texgen_reflection", F(NV_texgen_reflection
) },
100 { ON
, "GL_PGI_misc_hints", F(PGI_misc_hints
) },
101 { ON
, "GL_SGI_color_matrix", F(SGI_color_matrix
) },
102 { ON
, "GL_SGI_color_table", F(SGI_color_table
) },
103 { ON
, "GL_SGIS_pixel_texture", F(SGIS_pixel_texture
) },
104 { ON
, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp
) },
105 { ON
, "GL_SGIX_pixel_texture", F(SGIX_pixel_texture
) },
106 { OFF
, "GL_3DFX_texture_compression_FXT1", F(_3DFX_texture_compression_FXT1
) }
113 int gl_extensions_add( GLcontext
*ctx
,
116 GLboolean
*flag_ptr
)
118 if (ctx
->Extensions
.ext_string
== 0)
120 struct extension
*t
= MALLOC_STRUCT(extension
);
121 t
->enabled
= enabled
;
122 strncpy(t
->name
, name
, MAX_EXT_NAMELEN
);
123 t
->name
[MAX_EXT_NAMELEN
] = 0;
125 insert_at_tail( ctx
->Extensions
.ext_list
, t
);
133 * Either enable or disable the named extension.
135 static int set_extension( GLcontext
*ctx
, const char *name
, GLint state
)
138 foreach( i
, ctx
->Extensions
.ext_list
)
139 if (strncmp(i
->name
, name
, MAX_EXT_NAMELEN
) == 0)
142 if (i
== ctx
->Extensions
.ext_list
)
145 if (i
->flag
) *(i
->flag
) = state
;
151 int gl_extensions_enable( GLcontext
*ctx
, const char *name
)
153 if (ctx
->Extensions
.ext_string
== 0)
154 return set_extension( ctx
, name
, 1 );
159 int gl_extensions_disable( GLcontext
*ctx
, const char *name
)
161 if (ctx
->Extensions
.ext_string
== 0)
162 return set_extension( ctx
, name
, 0 );
168 * Test if the named extension is enabled in this context.
170 GLboolean
gl_extension_is_enabled( GLcontext
*ctx
, const char *name
)
173 foreach( i
, ctx
->Extensions
.ext_list
)
174 if (strncmp(i
->name
, name
, MAX_EXT_NAMELEN
) == 0) {
185 void gl_extensions_dtr( GLcontext
*ctx
)
187 struct extension
*i
, *nexti
;
189 if (ctx
->Extensions
.ext_string
) {
190 FREE( ctx
->Extensions
.ext_string
);
191 ctx
->Extensions
.ext_string
= 0;
194 if (ctx
->Extensions
.ext_list
) {
195 foreach_s( i
, nexti
, ctx
->Extensions
.ext_list
) {
196 remove_from_list( i
);
200 FREE(ctx
->Extensions
.ext_list
);
201 ctx
->Extensions
.ext_list
= 0;
206 void gl_extensions_ctr( GLcontext
*ctx
)
209 GLboolean
*base
= (GLboolean
*)&ctx
->Extensions
;
211 ctx
->Extensions
.ext_string
= 0;
212 ctx
->Extensions
.ext_list
= MALLOC_STRUCT(extension
);
213 make_empty_list( ctx
->Extensions
.ext_list
);
215 for (i
= 0 ; i
< Elements(default_extensions
) ; i
++) {
218 if (default_extensions
[i
].flag_offset
)
219 ptr
= base
+ default_extensions
[i
].flag_offset
;
221 gl_extensions_add( ctx
,
222 default_extensions
[i
].enabled
,
223 default_extensions
[i
].name
,
229 const char *gl_extensions_get_string( GLcontext
*ctx
)
231 if (ctx
->Extensions
.ext_string
== 0)
236 foreach (i
, ctx
->Extensions
.ext_list
)
238 len
+= strlen(i
->name
) + 1;
243 str
= (char *)MALLOC(len
* sizeof(char));
244 ctx
->Extensions
.ext_string
= str
;
246 foreach (i
, ctx
->Extensions
.ext_list
)
248 strcpy(str
, i
->name
);
256 return ctx
->Extensions
.ext_string
;