[OPENGL32/MESA]
[reactos.git] / reactos / dll / opengl / 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 /**
28 * \file
29 * \brief Extension handling
30 */
31
32 #include <precomp.h>
33
34 #define ALIGN(value, alignment) (((value) + alignment - 1) & ~(alignment - 1))
35
36 /**
37 * \brief An element of the \c extension_table.
38 */
39 struct extension {
40 /** Name of extension, such as "GL_ARB_depth_clamp". */
41 const char *name;
42
43 /** Offset (in bytes) of the corresponding member in struct gl_extensions. */
44 size_t offset;
45
46 /** Year the extension was proposed or approved. Used to sort the
47 * extension string chronologically. */
48 uint16_t year;
49 };
50
51
52 /**
53 * Given a member \c x of struct gl_extensions, return offset of
54 * \c x in bytes.
55 */
56 #define o(x) offsetof(struct gl_extensions, x)
57
58
59 /**
60 * \brief Table of supported OpenGL extensions for all API's.
61 */
62 static const struct extension extension_table[] = {
63 /* ARB Extensions */
64 { "GL_ARB_map_buffer_range", o(ARB_map_buffer_range), 2008 },
65 { "GL_ARB_multisample", o(dummy_true), 1994 },
66 { "GL_ARB_point_parameters", o(EXT_point_parameters), 1997 },
67 { "GL_ARB_point_sprite", o(ARB_point_sprite), 2003 },
68 { "GL_ARB_texture_cube_map", o(ARB_texture_cube_map), 1999 },
69 { "GL_ARB_texture_env_add", o(dummy_true), 1999 },
70 { "GL_ARB_texture_env_combine", o(ARB_texture_env_combine), 2001 },
71 { "GL_ARB_texture_env_crossbar", o(ARB_texture_env_crossbar), 2001 },
72 { "GL_ARB_texture_env_dot3", o(ARB_texture_env_dot3), 2001 },
73 { "GL_ARB_texture_mirrored_repeat", o(dummy_true), 2001 },
74 { "GL_ARB_texture_non_power_of_two", o(ARB_texture_non_power_of_two), 2003 },
75 { "GL_ARB_texture_storage", o(ARB_texture_storage), 2011 },
76 { "GL_ARB_transpose_matrix", o(ARB_transpose_matrix), 1999 },
77 { "GL_ARB_vertex_array_object", o(ARB_vertex_array_object), 2006 },
78 { "GL_ARB_vertex_buffer_object", o(dummy_true), 2003 },
79 { "GL_ARB_window_pos", o(ARB_window_pos), 2001 },
80 /* EXT extensions */
81 { "GL_EXT_abgr", o(dummy_true), 1995 },
82 { "GL_EXT_bgra", o(dummy_true), 1995 },
83 { "GL_EXT_blend_color", o(EXT_blend_color), 1995 },
84 { "GL_EXT_blend_equation_separate", o(EXT_blend_equation_separate), 2003 },
85 { "GL_EXT_blend_func_separate", o(EXT_blend_func_separate), 1999 },
86 { "GL_EXT_blend_minmax", o(EXT_blend_minmax), 1995 },
87 { "GL_EXT_blend_subtract", o(dummy_true), 1995 },
88 { "GL_EXT_clip_volume_hint", o(EXT_clip_volume_hint), 1996 },
89 { "GL_EXT_compiled_vertex_array", o(EXT_compiled_vertex_array), 1996 },
90 { "GL_EXT_copy_texture", o(dummy_true), 1995 },
91 { "GL_EXT_depth_bounds_test", o(EXT_depth_bounds_test), 2002 },
92 { "GL_EXT_draw_range_elements", o(EXT_draw_range_elements), 1997 },
93 { "GL_EXT_fog_coord", o(EXT_fog_coord), 1999 },
94 { "GL_EXT_packed_pixels", o(EXT_packed_pixels), 1997 },
95 { "GL_EXT_point_parameters", o(EXT_point_parameters), 1997 },
96 { "GL_EXT_polygon_offset", o(dummy_true), 1995 },
97 { "GL_EXT_rescale_normal", o(EXT_rescale_normal), 1997 },
98 { "GL_EXT_secondary_color", o(EXT_secondary_color), 1999 },
99 { "GL_EXT_separate_shader_objects", o(EXT_separate_shader_objects), 2008 },
100 { "GL_EXT_separate_specular_color", o(EXT_separate_specular_color), 1997 },
101 { "GL_EXT_shadow_funcs", o(EXT_shadow_funcs), 2002 },
102 { "GL_EXT_stencil_wrap", o(dummy_true), 2002 },
103 { "GL_EXT_subtexture", o(dummy_true), 1995 },
104 { "GL_EXT_texture3D", o(EXT_texture3D), 1996 },
105 { "GL_EXT_texture_cube_map", o(ARB_texture_cube_map), 2001 },
106 { "GL_EXT_texture_env_add", o(dummy_true), 1999 },
107 { "GL_EXT_texture_env_combine", o(dummy_true), 2000 },
108 { "GL_EXT_texture_env_dot3", o(EXT_texture_env_dot3), 2000 },
109 { "GL_EXT_texture_filter_anisotropic", o(EXT_texture_filter_anisotropic), 1999 },
110 { "GL_EXT_texture_integer", o(EXT_texture_integer), 2006 },
111 { "GL_EXT_texture_object", o(dummy_true), 1995 },
112 { "GL_EXT_texture", o(dummy_true), 1996 },
113 { "GL_EXT_vertex_array", o(dummy_true), 1995 },
114
115 /* Vendor extensions */
116 { "GL_APPLE_object_purgeable", o(APPLE_object_purgeable), 2006 },
117 { "GL_APPLE_packed_pixels", o(APPLE_packed_pixels), 2002 },
118 { "GL_APPLE_vertex_array_object", o(APPLE_vertex_array_object), 2002 },
119 { "GL_ATI_blend_equation_separate", o(EXT_blend_equation_separate), 2003 },
120 { "GL_ATI_texture_env_combine3", o(ATI_texture_env_combine3), 2002 },
121 { "GL_IBM_multimode_draw_arrays", o(IBM_multimode_draw_arrays), 1998 },
122 { "GL_IBM_rasterpos_clip", o(IBM_rasterpos_clip), 1996 },
123 { "GL_IBM_texture_mirrored_repeat", o(dummy_true), 1998 },
124 { "GL_INGR_blend_func_separate", o(EXT_blend_func_separate), 1999 },
125 { "GL_MESA_pack_invert", o(MESA_pack_invert), 2002 },
126 { "GL_MESA_resize_buffers", o(MESA_resize_buffers), 1999 },
127 { "GL_MESA_window_pos", o(ARB_window_pos), 2000 },
128 { "GL_MESA_ycbcr_texture", o(MESA_ycbcr_texture), 2002 },
129 { "GL_NV_blend_square", o(NV_blend_square), 1999 },
130 { "GL_NV_fog_distance", o(NV_fog_distance), 2001 },
131 { "GL_NV_light_max_exponent", o(NV_light_max_exponent), 1999 },
132 { "GL_NV_point_sprite", o(NV_point_sprite), 2001 },
133 { "GL_NV_texgen_reflection", o(NV_texgen_reflection), 1999 },
134 { "GL_NV_texture_barrier", o(NV_texture_barrier), 2009 },
135 { "GL_NV_texture_env_combine4", o(NV_texture_env_combine4), 1999 },
136
137 { 0, 0, 0},
138 };
139
140
141 /**
142 * Given an extension name, lookup up the corresponding member of struct
143 * gl_extensions and return that member's offset (in bytes). If the name is
144 * not found in the \c extension_table, return 0.
145 *
146 * \param name Name of extension.
147 * \return Offset of member in struct gl_extensions.
148 */
149 static size_t
150 name_to_offset(const char* name)
151 {
152 const struct extension *i;
153
154 if (name == 0)
155 return 0;
156
157 for (i = extension_table; i->name != 0; ++i) {
158 if (strcmp(name, i->name) == 0)
159 return i->offset;
160 }
161
162 return 0;
163 }
164
165
166 /**
167 * \brief Extensions enabled by default.
168 *
169 * These extensions are enabled by _mesa_init_extensions().
170 *
171 * XXX: Should these defaults also apply to GLES?
172 */
173 static const size_t default_extensions[] = {
174 o(ARB_transpose_matrix),
175 o(ARB_window_pos),
176
177 o(EXT_compiled_vertex_array),
178 o(EXT_draw_range_elements),
179 o(EXT_packed_pixels),
180 o(EXT_rescale_normal),
181 o(EXT_separate_specular_color),
182 o(EXT_texture3D),
183
184 /* Vendor Extensions */
185 o(APPLE_packed_pixels),
186 o(IBM_multimode_draw_arrays),
187 o(IBM_rasterpos_clip),
188 o(NV_light_max_exponent),
189 o(NV_texgen_reflection),
190
191 0,
192 };
193
194
195 /**
196 * Enable all extensions suitable for a software-only renderer.
197 * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc.
198 */
199 void
200 _mesa_enable_sw_extensions(struct gl_context *ctx)
201 {
202 ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
203 ctx->Extensions.ARB_point_sprite = GL_TRUE;
204 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
205 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
206 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
207 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
208 /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/
209 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
210 ctx->Extensions.ARB_texture_storage = GL_TRUE;
211 ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
212 ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
213 #if FEATURE_APPLE_object_purgeable
214 ctx->Extensions.APPLE_object_purgeable = GL_TRUE;
215 #endif
216 ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
217 ctx->Extensions.EXT_blend_color = GL_TRUE;
218 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
219 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
220 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
221 ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
222 ctx->Extensions.EXT_fog_coord = GL_TRUE;
223 ctx->Extensions.EXT_point_parameters = GL_TRUE;
224 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
225 ctx->Extensions.EXT_secondary_color = GL_TRUE;
226 ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
227 ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE;
228 /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/
229 ctx->Extensions.MESA_pack_invert = GL_TRUE;
230 ctx->Extensions.MESA_resize_buffers = GL_TRUE;
231 ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
232 ctx->Extensions.NV_blend_square = GL_TRUE;
233 /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/
234 ctx->Extensions.NV_point_sprite = GL_TRUE;
235 ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
236 /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/
237 #if FEATURE_texture_fxt1
238 _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
239 #endif
240 }
241
242
243 /**
244 * Enable all OpenGL 1.3 features and extensions.
245 * A convenience function to be called by drivers.
246 */
247 void
248 _mesa_enable_1_3_extensions(struct gl_context *ctx)
249 {
250 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
251 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
252 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
253 /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/
254 }
255
256
257
258 /**
259 * Enable all OpenGL 1.4 features and extensions.
260 * A convenience function to be called by drivers.
261 */
262 void
263 _mesa_enable_1_4_extensions(struct gl_context *ctx)
264 {
265 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
266 ctx->Extensions.ARB_window_pos = GL_TRUE;
267 ctx->Extensions.EXT_blend_color = GL_TRUE;
268 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
269 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
270 ctx->Extensions.EXT_fog_coord = GL_TRUE;
271 ctx->Extensions.EXT_point_parameters = GL_TRUE;
272 ctx->Extensions.EXT_secondary_color = GL_TRUE;
273 }
274
275
276 /**
277 * Enable all OpenGL 1.5 features and extensions.
278 * A convenience function to be called by drivers.
279 */
280 void
281 _mesa_enable_1_5_extensions(struct gl_context *ctx)
282 {
283 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
284 }
285
286
287 /**
288 * Enable all OpenGL 2.0 features and extensions.
289 * A convenience function to be called by drivers.
290 */
291 void
292 _mesa_enable_2_0_extensions(struct gl_context *ctx)
293 {
294 ctx->Extensions.ARB_point_sprite = GL_TRUE;
295 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
296 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
297 }
298
299
300 /**
301 * Enable all OpenGL 2.1 features and extensions.
302 * A convenience function to be called by drivers.
303 */
304 void
305 _mesa_enable_2_1_extensions(struct gl_context *ctx)
306 {
307 }
308
309
310 /**
311 * Either enable or disable the named extension.
312 * \return GL_TRUE for success, GL_FALSE if invalid extension name
313 */
314 static GLboolean
315 set_extension( struct gl_context *ctx, const char *name, GLboolean state )
316 {
317 size_t offset;
318
319 if (ctx->Extensions.String) {
320 /* The string was already queried - can't change it now! */
321 _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name);
322 return GL_FALSE;
323 }
324
325 offset = name_to_offset(name);
326 if (offset == 0) {
327 _mesa_problem(ctx, "Trying to enable/disable unknown extension %s",
328 name);
329 return GL_FALSE;
330 } else if (offset == o(dummy_true) && state == GL_FALSE) {
331 _mesa_problem(ctx, "Trying to disable a permanently enabled extension: "
332 "%s", name);
333 return GL_FALSE;
334 } else {
335 GLboolean *base = (GLboolean *) &ctx->Extensions;
336 base[offset] = state;
337 return GL_TRUE;
338 }
339 }
340
341
342 /**
343 * Enable the named extension.
344 * Typically called by drivers.
345 */
346 void
347 _mesa_enable_extension( struct gl_context *ctx, const char *name )
348 {
349 if (!set_extension(ctx, name, GL_TRUE))
350 _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
351 }
352
353
354 /**
355 * Disable the named extension.
356 * XXX is this really needed???
357 */
358 void
359 _mesa_disable_extension( struct gl_context *ctx, const char *name )
360 {
361 if (!set_extension(ctx, name, GL_FALSE))
362 _mesa_problem(ctx, "Trying to disable unknown extension: %s", name);
363 }
364
365
366 /**
367 * Test if the named extension is enabled in this context.
368 */
369 GLboolean
370 _mesa_extension_is_enabled( struct gl_context *ctx, const char *name )
371 {
372 size_t offset;
373 GLboolean *base;
374
375 if (name == 0)
376 return GL_FALSE;
377
378 offset = name_to_offset(name);
379 if (offset == 0)
380 return GL_FALSE;
381 base = (GLboolean *) &ctx->Extensions;
382 return base[offset];
383 }
384
385
386 /**
387 * \brief Apply the \c MESA_EXTENSION_OVERRIDE environment variable.
388 *
389 * \c MESA_EXTENSION_OVERRIDE is a space-separated list of extensions to
390 * enable or disable. The list is processed thus:
391 * - Enable recognized extension names that are prefixed with '+'.
392 * - Disable recognized extension names that are prefixed with '-'.
393 * - Enable recognized extension names that are not prefixed.
394 * - Collect unrecognized extension names in a new string.
395 *
396 * \return Space-separated list of unrecognized extension names (which must
397 * be freed). Does not return \c NULL.
398 */
399 static char *
400 get_extension_override( struct gl_context *ctx )
401 {
402 const char *env_const = _mesa_getenv("MESA_EXTENSION_OVERRIDE");
403 char *env;
404 char *ext;
405 char *extra_exts;
406 int len;
407
408 if (env_const == NULL) {
409 /* Return the empty string rather than NULL. This simplifies the logic
410 * of client functions. */
411 return calloc(4, sizeof(char));
412 }
413
414 /* extra_exts: List of unrecognized extensions. */
415 extra_exts = calloc(ALIGN(strlen(env_const) + 2, 4), sizeof(char));
416
417 /* Copy env_const because strtok() is destructive. */
418 env = _strdup(env_const);
419 for (ext = strtok(env, " "); ext != NULL; ext = strtok(NULL, " ")) {
420 int enable;
421 int recognized;
422 switch (ext[0]) {
423 case '+':
424 enable = 1;
425 ++ext;
426 break;
427 case '-':
428 enable = 0;
429 ++ext;
430 break;
431 default:
432 enable = 1;
433 break;
434 }
435 recognized = set_extension(ctx, ext, enable);
436 if (!recognized) {
437 strcat(extra_exts, ext);
438 strcat(extra_exts, " ");
439 }
440 }
441
442 free(env);
443
444 /* Remove trailing space. */
445 len = strlen(extra_exts);
446 if (extra_exts[len - 1] == ' ')
447 extra_exts[len - 1] = '\0';
448
449 return extra_exts;
450 }
451
452
453 /**
454 * \brief Initialize extension tables and enable default extensions.
455 *
456 * This should be called during context initialization.
457 * Note: Sets gl_extensions.dummy_true to true.
458 */
459 void
460 _mesa_init_extensions( struct gl_context *ctx )
461 {
462 GLboolean *base = (GLboolean *) &ctx->Extensions;
463 GLboolean *sentinel = base + o(extension_sentinel);
464 GLboolean *i;
465 const size_t *j;
466
467 /* First, turn all extensions off. */
468 for (i = base; i != sentinel; ++i)
469 *i = GL_FALSE;
470
471 /* Then, selectively turn default extensions on. */
472 ctx->Extensions.dummy_true = GL_TRUE;
473 for (j = default_extensions; *j != 0; ++j)
474 base[*j] = GL_TRUE;
475 }
476
477
478 typedef unsigned short extension_index;
479
480
481 /**
482 * Compare two entries of the extensions table. Sorts first by year,
483 * then by name.
484 *
485 * Arguments are indices into extension_table.
486 */
487 static int
488 extension_compare(const void *p1, const void *p2)
489 {
490 extension_index i1 = * (const extension_index *) p1;
491 extension_index i2 = * (const extension_index *) p2;
492 const struct extension *e1 = &extension_table[i1];
493 const struct extension *e2 = &extension_table[i2];
494 int res;
495
496 res = (int)e1->year - (int)e2->year;
497
498 if (res == 0) {
499 res = strcmp(e1->name, e2->name);
500 }
501
502 return res;
503 }
504
505
506 /**
507 * Construct the GL_EXTENSIONS string. Called the first time that
508 * glGetString(GL_EXTENSIONS) is called.
509 */
510 GLubyte*
511 _mesa_make_extension_string(struct gl_context *ctx)
512 {
513 /* The extension string. */
514 char *exts = 0;
515 /* Length of extension string. */
516 size_t length = 0;
517 /* Number of extensions */
518 unsigned count;
519 /* Indices of the extensions sorted by year */
520 extension_index *extension_indices;
521 /* String of extra extensions. */
522 char *extra_extensions = get_extension_override(ctx);
523 GLboolean *base = (GLboolean *) &ctx->Extensions;
524 const struct extension *i;
525 unsigned j;
526 unsigned maxYear = ~0;
527
528 /* Check if the MESA_EXTENSION_MAX_YEAR env var is set */
529 {
530 const char *env = getenv("MESA_EXTENSION_MAX_YEAR");
531 if (env) {
532 maxYear = atoi(env);
533 _mesa_debug(ctx, "Note: limiting GL extensions to %u or earlier\n",
534 maxYear);
535 }
536 }
537
538 /* Compute length of the extension string. */
539 count = 0;
540 for (i = extension_table; i->name != 0; ++i) {
541 if (base[i->offset] &&
542 i->year <= maxYear) {
543 length += strlen(i->name) + 1; /* +1 for space */
544 ++count;
545 }
546 }
547 if (extra_extensions != NULL)
548 length += 1 + strlen(extra_extensions); /* +1 for space */
549
550 exts = (char *) calloc(ALIGN(length + 1, 4), sizeof(char));
551 if (exts == NULL) {
552 free(extra_extensions);
553 return NULL;
554 }
555
556 extension_indices = malloc(count * sizeof(extension_index));
557 if (extension_indices == NULL) {
558 free(exts);
559 free(extra_extensions);
560 return NULL;
561 }
562
563 /* Sort extensions in chronological order because certain old applications (e.g.,
564 * Quake3 demo) store the extension list in a static size buffer so chronologically
565 * order ensure that the extensions that such applications expect will fit into
566 * that buffer.
567 */
568 j = 0;
569 for (i = extension_table; i->name != 0; ++i) {
570 if (base[i->offset] &&
571 i->year <= maxYear) {
572 extension_indices[j++] = i - extension_table;
573 }
574 }
575 assert(j == count);
576 qsort(extension_indices, count, sizeof *extension_indices, extension_compare);
577
578 /* Build the extension string.*/
579 for (j = 0; j < count; ++j) {
580 i = &extension_table[extension_indices[j]];
581 assert(base[i->offset]);
582 strcat(exts, i->name);
583 strcat(exts, " ");
584 }
585 free(extension_indices);
586 if (extra_extensions != 0) {
587 strcat(exts, extra_extensions);
588 free(extra_extensions);
589 }
590
591 return (GLubyte *) exts;
592 }
593
594 /**
595 * Return number of enabled extensions.
596 */
597 GLuint
598 _mesa_get_extension_count(struct gl_context *ctx)
599 {
600 GLboolean *base;
601 const struct extension *i;
602
603 /* only count once */
604 if (ctx->Extensions.Count != 0)
605 return ctx->Extensions.Count;
606
607 base = (GLboolean *) &ctx->Extensions;
608 for (i = extension_table; i->name != 0; ++i) {
609 if (base[i->offset]) {
610 ctx->Extensions.Count++;
611 }
612 }
613 return ctx->Extensions.Count;
614 }
615
616 /**
617 * Return name of i-th enabled extension
618 */
619 const GLubyte *
620 _mesa_get_enabled_extension(struct gl_context *ctx, GLuint index)
621 {
622 const GLboolean *base;
623 size_t n;
624 const struct extension *i;
625
626 if (index < 0)
627 return NULL;
628
629 base = (GLboolean*) &ctx->Extensions;
630 n = 0;
631 for (i = extension_table; i->name != 0; ++i) {
632 if (n == index && base[i->offset]) {
633 return (GLubyte*) i->name;
634 } else if (base[i->offset]) {
635 ++n;
636 }
637 }
638
639 return NULL;
640 }