Implementation of GL_EXT_pixel_buffer_object extension.
[mesa.git] / src / mesa / main / extensions.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.1
4 *
5 * Copyright (C) 1999-2004 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)(unsigned long)&(((struct gl_extensions *)0)->x)
35 #define ON GL_TRUE
36 #define OFF GL_FALSE
37
38
39 static const struct {
40 GLboolean enabled;
41 const char *name;
42 int flag_offset;
43 } default_extensions[] = {
44 { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) },
45 { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) },
46 { OFF, "GL_ARB_imaging", F(ARB_imaging) },
47 { OFF, "GL_ARB_multisample", F(ARB_multisample) },
48 { OFF, "GL_ARB_multitexture", F(ARB_multitexture) },
49 { OFF, "GL_ARB_occlusion_query", F(ARB_occlusion_query) },
50 { OFF, "GL_ARB_point_parameters", F(EXT_point_parameters) },
51 { OFF, "GL_ARB_point_sprite", F(ARB_point_sprite) },
52 { OFF, "GL_ARB_shadow", F(ARB_shadow) },
53 { OFF, "GL_ARB_shadow_ambient", F(SGIX_shadow_ambient) },
54 { OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) },
55 { OFF, "GL_ARB_texture_compression", F(ARB_texture_compression) },
56 { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) },
57 { OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) },
58 { OFF, "GL_ARB_texture_env_combine", F(ARB_texture_env_combine) },
59 { OFF, "GL_ARB_texture_env_crossbar", F(ARB_texture_env_crossbar) },
60 { OFF, "GL_ARB_texture_env_dot3", F(ARB_texture_env_dot3) },
61 { OFF, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
62 { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)},
63 { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) },
64 { OFF, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) },
65 { OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) },
66 { ON, "GL_ARB_window_pos", F(ARB_window_pos) },
67 { ON, "GL_EXT_abgr", F(EXT_abgr) },
68 { ON, "GL_EXT_bgra", F(EXT_bgra) },
69 { OFF, "GL_EXT_blend_color", F(EXT_blend_color) },
70 { OFF, "GL_EXT_blend_equation_separate", F(EXT_blend_equation_separate) },
71 { OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) },
72 { OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) },
73 { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) },
74 { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) },
75 { ON, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) },
76 { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) },
77 { OFF, "GL_EXT_convolution", F(EXT_convolution) },
78 { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) },
79 { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) },
80 { ON, "GL_EXT_draw_range_elements", F(EXT_draw_range_elements) },
81 { OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) },
82 { OFF, "GL_EXT_histogram", F(EXT_histogram) },
83 { OFF, "GL_EXT_multi_draw_arrays", F(EXT_multi_draw_arrays) },
84 { ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) },
85 { OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) },
86 { OFF, "GL_EXT_pixel_buffer_object", F(EXT_pixel_buffer_object) },
87 { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) },
88 { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) },
89 { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) },
90 { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) },
91 { ON, "GL_EXT_separate_specular_color", F(EXT_separate_specular_color) },
92 { OFF, "GL_EXT_shadow_funcs", F(EXT_shadow_funcs) },
93 { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) },
94 { OFF, "GL_EXT_stencil_two_side", F(EXT_stencil_two_side) },
95 { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) },
96 { ON, "GL_EXT_subtexture", F(EXT_subtexture) },
97 { ON, "GL_EXT_texture", F(EXT_texture) },
98 { ON, "GL_EXT_texture3D", F(EXT_texture3D) },
99 { OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) },
100 { ON, "GL_EXT_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
101 { OFF, "GL_EXT_texture_env_add", F(EXT_texture_env_add) },
102 { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) },
103 { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) },
104 { OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) },
105 { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) },
106 { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) },
107 { ON, "GL_EXT_texture_object", F(EXT_texture_object) },
108 { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) },
109 { ON, "GL_EXT_vertex_array", F(EXT_vertex_array) },
110 { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) },
111 { OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) },
112 { OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) },
113 { ON, "GL_APPLE_packed_pixels", F(APPLE_packed_pixels) },
114 { OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate) },
115 { OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)},
116 { OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)},
117 { OFF, "GL_HP_occlusion_test", F(HP_occlusion_test) },
118 { OFF, "GL_IBM_multimode_draw_arrays", F(IBM_multimode_draw_arrays) },
119 { ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) },
120 { OFF, "GL_IBM_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
121 { OFF, "GL_INGR_blend_func_separate", F(EXT_blend_func_separate) },
122 { OFF, "GL_MESA_pack_invert", F(MESA_pack_invert) },
123 { OFF, "GL_MESA_packed_depth_stencil", F(MESA_packed_depth_stencil) },
124 { OFF, "GL_MESA_program_debug", F(MESA_program_debug) },
125 { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) },
126 { OFF, "GL_MESA_ycbcr_texture", F(MESA_ycbcr_texture) },
127 { ON, "GL_MESA_window_pos", F(ARB_window_pos) },
128 { OFF, "GL_NV_blend_square", F(NV_blend_square) },
129 { OFF, "GL_NV_fragment_program", F(NV_fragment_program) },
130 { ON, "GL_NV_light_max_exponent", F(NV_light_max_exponent) },
131 { OFF, "GL_NV_point_sprite", F(NV_point_sprite) },
132 { OFF, "GL_NV_texture_rectangle", F(NV_texture_rectangle) },
133 { ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) },
134 { OFF, "GL_NV_vertex_program", F(NV_vertex_program) },
135 { OFF, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1) },
136 { OFF, "GL_SGI_color_matrix", F(SGI_color_matrix) },
137 { OFF, "GL_SGI_color_table", F(SGI_color_table) },
138 { OFF, "GL_SGI_texture_color_table", F(SGI_texture_color_table) },
139 { OFF, "GL_SGIS_generate_mipmap", F(SGIS_generate_mipmap) },
140 { OFF, "GL_SGIS_pixel_texture", F(SGIS_pixel_texture) },
141 { OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) },
142 { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
143 { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) },
144 { OFF, "GL_SGIX_depth_texture", F(SGIX_depth_texture) },
145 { OFF, "GL_SGIX_pixel_texture", F(SGIX_pixel_texture) },
146 { OFF, "GL_SGIX_shadow", F(SGIX_shadow) },
147 { OFF, "GL_SGIX_shadow_ambient", F(SGIX_shadow_ambient) },
148 { OFF, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) },
149 { OFF, "GL_S3_s3tc", F(S3_s3tc) },
150 };
151
152
153
154 /**
155 * Enable all extensions suitable for a software-only renderer.
156 * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc.
157 */
158 void
159 _mesa_enable_sw_extensions(GLcontext *ctx)
160 {
161 ctx->Extensions.ARB_depth_texture = GL_TRUE;
162 #if FEATURE_ARB_fragment_program
163 /*ctx->Extensions.ARB_fragment_program = GL_TRUE;*/
164 #endif
165 ctx->Extensions.ARB_imaging = GL_TRUE;
166 ctx->Extensions.ARB_multitexture = GL_TRUE;
167 #if FEATURE_ARB_occlusion_query
168 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
169 #endif
170 ctx->Extensions.ARB_point_sprite = GL_TRUE;
171 ctx->Extensions.ARB_shadow = GL_TRUE;
172 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
173 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
174 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
175 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
176 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
177 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
178 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
179 #if FEATURE_ARB_vertex_program
180 /*ctx->Extensions.ARB_vertex_program = GL_TRUE;*/
181 #endif
182 #if FEATURE_ARB_vertex_buffer_object
183 ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;
184 #endif
185 ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
186 ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
187 ctx->Extensions.EXT_blend_color = GL_TRUE;
188 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
189 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
190 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
191 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
192 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
193 ctx->Extensions.EXT_convolution = GL_TRUE;
194 ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
195 ctx->Extensions.EXT_fog_coord = GL_TRUE;
196 ctx->Extensions.EXT_histogram = GL_TRUE;
197 ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;
198 ctx->Extensions.EXT_paletted_texture = GL_TRUE;
199 #if FEATURE_EXT_pixel_buffer_object
200 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
201 #endif
202 ctx->Extensions.EXT_point_parameters = GL_TRUE;
203 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
204 ctx->Extensions.EXT_secondary_color = GL_TRUE;
205 ctx->Extensions.EXT_shared_texture_palette = GL_TRUE;
206 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
207 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
208 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
209 ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
210 ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
211 ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
212 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
213 ctx->Extensions.HP_occlusion_test = GL_TRUE;
214 ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;
215 ctx->Extensions.MESA_pack_invert = GL_TRUE;
216 #if FEATURE_MESA_program_debug
217 ctx->Extensions.MESA_program_debug = GL_TRUE;
218 #endif
219 ctx->Extensions.MESA_resize_buffers = GL_TRUE;
220 ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
221 ctx->Extensions.NV_blend_square = GL_TRUE;
222 /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/
223 ctx->Extensions.NV_point_sprite = GL_TRUE;
224 ctx->Extensions.NV_texture_rectangle = GL_TRUE;
225 /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/
226 #if FEATURE_NV_vertex_program
227 ctx->Extensions.NV_vertex_program = GL_TRUE;
228 ctx->Extensions.NV_vertex_program1_1 = GL_TRUE;
229 #endif
230 #if FEATURE_NV_fragment_program
231 ctx->Extensions.NV_fragment_program = GL_TRUE;
232 #endif
233 ctx->Extensions.SGI_color_matrix = GL_TRUE;
234 ctx->Extensions.SGI_color_table = GL_TRUE;
235 ctx->Extensions.SGI_texture_color_table = GL_TRUE;
236 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
237 ctx->Extensions.SGIS_pixel_texture = GL_TRUE;
238 ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE;
239 ctx->Extensions.SGIX_depth_texture = GL_TRUE;
240 ctx->Extensions.SGIX_pixel_texture = GL_TRUE;
241 ctx->Extensions.SGIX_shadow = GL_TRUE;
242 ctx->Extensions.SGIX_shadow_ambient = GL_TRUE;
243 }
244
245
246 /**
247 * Enable GL_ARB_imaging and all the EXT extensions that are subsets of it.
248 */
249 void
250 _mesa_enable_imaging_extensions(GLcontext *ctx)
251 {
252 ctx->Extensions.ARB_imaging = GL_TRUE;
253 ctx->Extensions.EXT_blend_color = GL_TRUE;
254 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
255 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
256 ctx->Extensions.EXT_convolution = GL_TRUE;
257 ctx->Extensions.EXT_histogram = GL_TRUE;
258 ctx->Extensions.SGI_color_matrix = GL_TRUE;
259 ctx->Extensions.SGI_color_table = GL_TRUE;
260 }
261
262
263
264 /**
265 * Enable all OpenGL 1.3 features and extensions.
266 * A convenience function to be called by drivers.
267 */
268 void
269 _mesa_enable_1_3_extensions(GLcontext *ctx)
270 {
271 ctx->Extensions.ARB_multisample = GL_TRUE;
272 ctx->Extensions.ARB_multitexture = GL_TRUE;
273 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
274 ctx->Extensions.ARB_texture_compression = GL_TRUE;
275 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
276 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
277 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
278 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
279 /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/
280 }
281
282
283
284 /**
285 * Enable all OpenGL 1.4 features and extensions.
286 * A convenience function to be called by drivers.
287 */
288 void
289 _mesa_enable_1_4_extensions(GLcontext *ctx)
290 {
291 ctx->Extensions.ARB_depth_texture = GL_TRUE;
292 ctx->Extensions.ARB_fragment_program = GL_TRUE;
293 ctx->Extensions.ARB_shadow = GL_TRUE;
294 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
295 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
296 ctx->Extensions.ARB_vertex_program = GL_TRUE;
297 ctx->Extensions.ARB_window_pos = GL_TRUE;
298 ctx->Extensions.EXT_blend_color = GL_TRUE;
299 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
300 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
301 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
302 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
303 ctx->Extensions.EXT_fog_coord = GL_TRUE;
304 ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;
305 ctx->Extensions.EXT_point_parameters = GL_TRUE;
306 ctx->Extensions.EXT_secondary_color = GL_TRUE;
307 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
308 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
309 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
310 }
311
312
313 /**
314 * Enable all OpenGL 1.5 features and extensions.
315 * A convenience function to be called by drivers.
316 */
317 void
318 _mesa_enable_1_5_extensions(GLcontext *ctx)
319 {
320 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
321 ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;
322 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
323 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
324 }
325
326
327 /**
328 * Either enable or disable the named extension.
329 */
330 static void
331 set_extension( GLcontext *ctx, const char *name, GLboolean state )
332 {
333 GLboolean *base = (GLboolean *) &ctx->Extensions;
334 GLuint i;
335
336 if (ctx->Extensions.String) {
337 /* The string was already queried - can't change it now! */
338 _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name);
339 return;
340 }
341
342 for (i = 0 ; i < Elements(default_extensions) ; i++) {
343 if (_mesa_strcmp(default_extensions[i].name, name) == 0) {
344 if (default_extensions[i].flag_offset) {
345 GLboolean *enabled = base + default_extensions[i].flag_offset;
346 *enabled = state;
347 }
348 return;
349 }
350 }
351 _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
352 }
353
354
355 /**
356 * Enable the named extension.
357 * Typically called by drivers.
358 */
359 void
360 _mesa_enable_extension( GLcontext *ctx, const char *name )
361 {
362 set_extension(ctx, name, GL_TRUE);
363 }
364
365
366 /**
367 * Disable the named extension.
368 * XXX is this really needed???
369 */
370 void
371 _mesa_disable_extension( GLcontext *ctx, const char *name )
372 {
373 set_extension(ctx, name, GL_FALSE);
374 }
375
376
377 /**
378 * Test if the named extension is enabled in this context.
379 */
380 GLboolean
381 _mesa_extension_is_enabled( GLcontext *ctx, const char *name )
382 {
383 const GLboolean *base = (const GLboolean *) &ctx->Extensions;
384 GLuint i;
385
386 for (i = 0 ; i < Elements(default_extensions) ; i++) {
387 if (_mesa_strcmp(default_extensions[i].name, name) == 0) {
388 if (!default_extensions[i].flag_offset)
389 return GL_TRUE;
390 return *(base + default_extensions[i].flag_offset);
391 }
392 }
393 return GL_FALSE;
394 }
395
396
397 /**
398 * Run through the default_extensions array above and set the
399 * ctx->Extensions.ARB/EXT_* flags accordingly.
400 * To be called during context initialization.
401 */
402 void
403 _mesa_init_extensions( GLcontext *ctx )
404 {
405 GLboolean *base = (GLboolean *) &ctx->Extensions;
406 GLuint i;
407
408 for (i = 0 ; i < Elements(default_extensions) ; i++) {
409 if (default_extensions[i].enabled &&
410 default_extensions[i].flag_offset) {
411 *(base + default_extensions[i].flag_offset) = GL_TRUE;
412 }
413 }
414 }
415
416
417 /**
418 * Construct the GL_EXTENSIONS string. Called the first time that
419 * glGetString(GL_EXTENSIONS) is called.
420 */
421 GLubyte *
422 _mesa_make_extension_string( GLcontext *ctx )
423 {
424 const GLboolean *base = (const GLboolean *) &ctx->Extensions;
425 GLuint extStrLen = 0;
426 GLubyte *s;
427 GLuint i;
428
429 /* first, compute length of the extension string */
430 for (i = 0 ; i < Elements(default_extensions) ; i++) {
431 if (!default_extensions[i].flag_offset ||
432 *(base + default_extensions[i].flag_offset)) {
433 extStrLen += _mesa_strlen(default_extensions[i].name) + 1;
434 }
435 }
436 s = (GLubyte *) _mesa_malloc(extStrLen);
437
438 /* second, build the extension string */
439 extStrLen = 0;
440 for (i = 0 ; i < Elements(default_extensions) ; i++) {
441 if (!default_extensions[i].flag_offset ||
442 *(base + default_extensions[i].flag_offset)) {
443 GLuint len = _mesa_strlen(default_extensions[i].name);
444 _mesa_memcpy(s + extStrLen, default_extensions[i].name, len);
445 extStrLen += len;
446 s[extStrLen] = (GLubyte) ' ';
447 extStrLen++;
448 }
449 }
450 ASSERT(extStrLen > 0);
451
452 s[extStrLen - 1] = 0;
453
454 return s;
455 }