extensions.c revision 4a49301e
17117f1b4Smrg/* 27117f1b4Smrg * Mesa 3-D graphics library 34a49301eSmrg * Version: 7.6 47117f1b4Smrg * 5c1f859d4Smrg * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 64a49301eSmrg * Copyright (C) 2009 VMware, Inc. All Rights Reserved. 77117f1b4Smrg * 87117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 97117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 107117f1b4Smrg * to deal in the Software without restriction, including without limitation 117117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 127117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 137117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 147117f1b4Smrg * 157117f1b4Smrg * The above copyright notice and this permission notice shall be included 167117f1b4Smrg * in all copies or substantial portions of the Software. 177117f1b4Smrg * 187117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 197117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 207117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 217117f1b4Smrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 227117f1b4Smrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 237117f1b4Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 247117f1b4Smrg */ 257117f1b4Smrg 267117f1b4Smrg 277117f1b4Smrg#include "glheader.h" 287117f1b4Smrg#include "imports.h" 297117f1b4Smrg#include "context.h" 307117f1b4Smrg#include "extensions.h" 317117f1b4Smrg#include "simple_list.h" 327117f1b4Smrg#include "mtypes.h" 337117f1b4Smrg 347117f1b4Smrg 354a49301eSmrg#define F(x) offsetof(struct gl_extensions, x) 367117f1b4Smrg#define ON GL_TRUE 377117f1b4Smrg#define OFF GL_FALSE 387117f1b4Smrg 397117f1b4Smrg 407117f1b4Smrg/* 417117f1b4Smrg * Note: The GL_MESAX_* extensions are placeholders for future ARB extensions. 427117f1b4Smrg */ 437117f1b4Smrgstatic const struct { 447117f1b4Smrg GLboolean enabled; 457117f1b4Smrg const char *name; 467117f1b4Smrg int flag_offset; 477117f1b4Smrg} default_extensions[] = { 484a49301eSmrg /* 494a49301eSmrg * TODO: Sort by year, to ensure that old extensions are listed first, so 504a49301eSmrg * that old applications that truncate the extension string get the basic 514a49301eSmrg * extensions, roughly corresponding to what existed then. 524a49301eSmrg * 534a49301eSmrg * The best example is quake3demo, which often misses 544a49301eSmrg * GL_EXT_compiled_vertex_array because it gets truncated. 554a49301eSmrg */ 564a49301eSmrg { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) }, 574a49301eSmrg { OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) }, 584a49301eSmrg { OFF, "GL_EXT_texture_env_add", F(EXT_texture_env_add) }, 594a49301eSmrg 604a49301eSmrg { OFF, "GL_ARB_copy_buffer", F(ARB_copy_buffer) }, 617117f1b4Smrg { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) }, 624a49301eSmrg { OFF, "GL_ARB_depth_clamp", F(ARB_depth_clamp) }, 634a49301eSmrg { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) }, 644a49301eSmrg { OFF, "GL_ARB_draw_elements_base_vertex", F(ARB_draw_elements_base_vertex) }, 657117f1b4Smrg { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) }, 66c1f859d4Smrg { OFF, "GL_ARB_fragment_program_shadow", F(ARB_fragment_program_shadow) }, 677117f1b4Smrg { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) }, 684a49301eSmrg { OFF, "GL_ARB_framebuffer_object", F(ARB_framebuffer_object) }, 697117f1b4Smrg { OFF, "GL_ARB_half_float_pixel", F(ARB_half_float_pixel) }, 707117f1b4Smrg { OFF, "GL_ARB_imaging", F(ARB_imaging) }, 714a49301eSmrg { OFF, "GL_ARB_map_buffer_range", F(ARB_map_buffer_range) }, 724a49301eSmrg { ON, "GL_ARB_multisample", F(ARB_multisample) }, 737117f1b4Smrg { OFF, "GL_ARB_multitexture", F(ARB_multitexture) }, 747117f1b4Smrg { OFF, "GL_ARB_occlusion_query", F(ARB_occlusion_query) }, 757117f1b4Smrg { OFF, "GL_ARB_pixel_buffer_object", F(EXT_pixel_buffer_object) }, 767117f1b4Smrg { OFF, "GL_ARB_point_parameters", F(EXT_point_parameters) }, 777117f1b4Smrg { OFF, "GL_ARB_point_sprite", F(ARB_point_sprite) }, 784a49301eSmrg { OFF, "GL_ARB_provoking_vertex", F(EXT_provoking_vertex) }, 794a49301eSmrg { OFF, "GL_ARB_seamless_cube_map", F(ARB_seamless_cube_map) }, 807117f1b4Smrg { OFF, "GL_ARB_shader_objects", F(ARB_shader_objects) }, 817117f1b4Smrg { OFF, "GL_ARB_shading_language_100", F(ARB_shading_language_100) }, 827117f1b4Smrg { OFF, "GL_ARB_shading_language_120", F(ARB_shading_language_120) }, 837117f1b4Smrg { OFF, "GL_ARB_shadow", F(ARB_shadow) }, 844a49301eSmrg { OFF, "GL_ARB_shadow_ambient", F(ARB_shadow_ambient) }, 854a49301eSmrg { OFF, "GL_ARB_sync", F(ARB_sync) }, 867117f1b4Smrg { OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) }, 874a49301eSmrg { ON, "GL_ARB_texture_compression", F(ARB_texture_compression) }, 887117f1b4Smrg { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) }, 897117f1b4Smrg { OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) }, 907117f1b4Smrg { OFF, "GL_ARB_texture_env_combine", F(ARB_texture_env_combine) }, 917117f1b4Smrg { OFF, "GL_ARB_texture_env_crossbar", F(ARB_texture_env_crossbar) }, 927117f1b4Smrg { OFF, "GL_ARB_texture_env_dot3", F(ARB_texture_env_dot3) }, 937117f1b4Smrg { OFF, "GL_MESAX_texture_float", F(ARB_texture_float) }, 947117f1b4Smrg { OFF, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)}, 957117f1b4Smrg { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)}, 967117f1b4Smrg { OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) }, 977117f1b4Smrg { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) }, 984a49301eSmrg { OFF, "GL_ARB_vertex_array_bgra", F(EXT_vertex_array_bgra) }, 994a49301eSmrg { OFF, "GL_ARB_vertex_array_object", F(ARB_vertex_array_object) }, 1004a49301eSmrg { ON, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) }, 1017117f1b4Smrg { OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) }, 1027117f1b4Smrg { OFF, "GL_ARB_vertex_shader", F(ARB_vertex_shader) }, 1037117f1b4Smrg { ON, "GL_ARB_window_pos", F(ARB_window_pos) }, 1047117f1b4Smrg { ON, "GL_EXT_abgr", F(EXT_abgr) }, 1057117f1b4Smrg { ON, "GL_EXT_bgra", F(EXT_bgra) }, 1067117f1b4Smrg { OFF, "GL_EXT_blend_color", F(EXT_blend_color) }, 1077117f1b4Smrg { OFF, "GL_EXT_blend_equation_separate", F(EXT_blend_equation_separate) }, 1087117f1b4Smrg { OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) }, 1097117f1b4Smrg { OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) }, 1107117f1b4Smrg { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) }, 1117117f1b4Smrg { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) }, 1124a49301eSmrg { OFF, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) }, 1137117f1b4Smrg { OFF, "GL_EXT_cull_vertex", F(EXT_cull_vertex) }, 1147117f1b4Smrg { OFF, "GL_EXT_convolution", F(EXT_convolution) }, 1157117f1b4Smrg { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) }, 1167117f1b4Smrg { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) }, 1177117f1b4Smrg { ON, "GL_EXT_draw_range_elements", F(EXT_draw_range_elements) }, 1187117f1b4Smrg { OFF, "GL_EXT_framebuffer_blit", F(EXT_framebuffer_blit) }, 1194a49301eSmrg { OFF, "GL_EXT_framebuffer_multisample", F(EXT_framebuffer_multisample) }, 1204a49301eSmrg { OFF, "GL_EXT_framebuffer_object", F(EXT_framebuffer_object) }, 1217117f1b4Smrg { OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) }, 1227117f1b4Smrg { OFF, "GL_EXT_gpu_program_parameters", F(EXT_gpu_program_parameters) }, 1237117f1b4Smrg { OFF, "GL_EXT_histogram", F(EXT_histogram) }, 1244a49301eSmrg { ON, "GL_EXT_multi_draw_arrays", F(EXT_multi_draw_arrays) }, 1257117f1b4Smrg { OFF, "GL_EXT_packed_depth_stencil", F(EXT_packed_depth_stencil) }, 1267117f1b4Smrg { ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) }, 1277117f1b4Smrg { OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) }, 1287117f1b4Smrg { OFF, "GL_EXT_pixel_buffer_object", F(EXT_pixel_buffer_object) }, 1297117f1b4Smrg { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) }, 1307117f1b4Smrg { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) }, 1314a49301eSmrg { OFF, "GL_EXT_provoking_vertex", F(EXT_provoking_vertex) }, 1327117f1b4Smrg { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) }, 1337117f1b4Smrg { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) }, 1347117f1b4Smrg { ON, "GL_EXT_separate_specular_color", F(EXT_separate_specular_color) }, 1357117f1b4Smrg { OFF, "GL_EXT_shadow_funcs", F(EXT_shadow_funcs) }, 1367117f1b4Smrg { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) }, 1377117f1b4Smrg { OFF, "GL_EXT_stencil_two_side", F(EXT_stencil_two_side) }, 1387117f1b4Smrg { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) }, 1397117f1b4Smrg { ON, "GL_EXT_subtexture", F(EXT_subtexture) }, 1407117f1b4Smrg { ON, "GL_EXT_texture", F(EXT_texture) }, 1417117f1b4Smrg { ON, "GL_EXT_texture3D", F(EXT_texture3D) }, 1424a49301eSmrg { OFF, "GL_EXT_texture_cube_map", F(ARB_texture_cube_map) }, 1437117f1b4Smrg { ON, "GL_EXT_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, 1447117f1b4Smrg { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) }, 1457117f1b4Smrg { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) }, 1467117f1b4Smrg { OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) }, 1477117f1b4Smrg { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) }, 1487117f1b4Smrg { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) }, 1497117f1b4Smrg { ON, "GL_EXT_texture_object", F(EXT_texture_object) }, 1507117f1b4Smrg { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) }, 1517117f1b4Smrg { OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) }, 1524a49301eSmrg { OFF, "GL_EXT_texture_swizzle", F(EXT_texture_swizzle) }, 1537117f1b4Smrg { OFF, "GL_EXT_timer_query", F(EXT_timer_query) }, 1547117f1b4Smrg { ON, "GL_EXT_vertex_array", F(EXT_vertex_array) }, 1554a49301eSmrg { OFF, "GL_EXT_vertex_array_bgra", F(EXT_vertex_array_bgra) }, 1567117f1b4Smrg { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) }, 1577117f1b4Smrg { OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) }, 1587117f1b4Smrg { OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) }, 1597117f1b4Smrg { ON, "GL_APPLE_packed_pixels", F(APPLE_packed_pixels) }, 1607117f1b4Smrg { OFF, "GL_APPLE_vertex_array_object", F(APPLE_vertex_array_object) }, 1617117f1b4Smrg { OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate) }, 1624a49301eSmrg { OFF, "GL_ATI_envmap_bumpmap", F(ATI_envmap_bumpmap) }, 1637117f1b4Smrg { OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)}, 1647117f1b4Smrg { OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)}, 1657117f1b4Smrg { OFF, "GL_ATI_fragment_shader", F(ATI_fragment_shader)}, 1667117f1b4Smrg { OFF, "GL_ATI_separate_stencil", F(ATI_separate_stencil)}, 1674a49301eSmrg { ON, "GL_IBM_multimode_draw_arrays", F(IBM_multimode_draw_arrays) }, 1687117f1b4Smrg { ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) }, 1697117f1b4Smrg { OFF, "GL_IBM_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)}, 1707117f1b4Smrg { OFF, "GL_INGR_blend_func_separate", F(EXT_blend_func_separate) }, 1717117f1b4Smrg { OFF, "GL_MESA_pack_invert", F(MESA_pack_invert) }, 1727117f1b4Smrg { OFF, "GL_MESA_packed_depth_stencil", F(MESA_packed_depth_stencil) }, 1737117f1b4Smrg { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) }, 174c1f859d4Smrg { OFF, "GL_MESA_texture_array", F(MESA_texture_array) }, 1754a49301eSmrg { OFF, "GL_MESA_texture_signed_rgba", F(MESA_texture_signed_rgba) }, 1767117f1b4Smrg { OFF, "GL_MESA_ycbcr_texture", F(MESA_ycbcr_texture) }, 1777117f1b4Smrg { ON, "GL_MESA_window_pos", F(ARB_window_pos) }, 1787117f1b4Smrg { OFF, "GL_NV_blend_square", F(NV_blend_square) }, 1794a49301eSmrg { OFF, "GL_NV_depth_clamp", F(ARB_depth_clamp) }, 1807117f1b4Smrg { OFF, "GL_NV_fragment_program", F(NV_fragment_program) }, 1814a49301eSmrg { OFF, "GL_NV_fragment_program_option", F(NV_fragment_program_option) }, 1827117f1b4Smrg { ON, "GL_NV_light_max_exponent", F(NV_light_max_exponent) }, 1834a49301eSmrg { OFF, "GL_NV_packed_depth_stencil", F(EXT_packed_depth_stencil) }, 1847117f1b4Smrg { OFF, "GL_NV_point_sprite", F(NV_point_sprite) }, 1854a49301eSmrg { OFF, "GL_NV_texture_env_combine4", F(NV_texture_env_combine4) }, 1867117f1b4Smrg { OFF, "GL_NV_texture_rectangle", F(NV_texture_rectangle) }, 1877117f1b4Smrg { ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) }, 1887117f1b4Smrg { OFF, "GL_NV_vertex_program", F(NV_vertex_program) }, 1897117f1b4Smrg { OFF, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1) }, 1907117f1b4Smrg { ON, "GL_OES_read_format", F(OES_read_format) }, 1917117f1b4Smrg { OFF, "GL_SGI_color_matrix", F(SGI_color_matrix) }, 1927117f1b4Smrg { OFF, "GL_SGI_color_table", F(SGI_color_table) }, 1937117f1b4Smrg { OFF, "GL_SGI_texture_color_table", F(SGI_texture_color_table) }, 1947117f1b4Smrg { OFF, "GL_SGIS_generate_mipmap", F(SGIS_generate_mipmap) }, 1957117f1b4Smrg { OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) }, 1967117f1b4Smrg { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, 1977117f1b4Smrg { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) }, 1984a49301eSmrg { ON, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) }, 1997117f1b4Smrg { OFF, "GL_S3_s3tc", F(S3_s3tc) }, 2007117f1b4Smrg}; 2017117f1b4Smrg 2027117f1b4Smrg 2037117f1b4Smrg 2047117f1b4Smrg/** 2057117f1b4Smrg * Enable all extensions suitable for a software-only renderer. 2067117f1b4Smrg * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc. 2077117f1b4Smrg */ 2087117f1b4Smrgvoid 2097117f1b4Smrg_mesa_enable_sw_extensions(GLcontext *ctx) 2107117f1b4Smrg{ 2114a49301eSmrg ctx->Extensions.ARB_copy_buffer = GL_TRUE; 2124a49301eSmrg ctx->Extensions.ARB_depth_clamp = GL_TRUE; 2137117f1b4Smrg ctx->Extensions.ARB_depth_texture = GL_TRUE; 2144a49301eSmrg /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ 2154a49301eSmrg ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE; 2167117f1b4Smrg#if FEATURE_ARB_fragment_program 2177117f1b4Smrg ctx->Extensions.ARB_fragment_program = GL_TRUE; 218c1f859d4Smrg ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE; 2197117f1b4Smrg#endif 2207117f1b4Smrg#if FEATURE_ARB_fragment_shader 2217117f1b4Smrg ctx->Extensions.ARB_fragment_shader = GL_TRUE; 2224a49301eSmrg#endif 2234a49301eSmrg#if FEATURE_ARB_framebuffer_object 2244a49301eSmrg ctx->Extensions.ARB_framebuffer_object = GL_TRUE; 2257117f1b4Smrg#endif 2267117f1b4Smrg ctx->Extensions.ARB_half_float_pixel = GL_TRUE; 2277117f1b4Smrg ctx->Extensions.ARB_imaging = GL_TRUE; 2284a49301eSmrg ctx->Extensions.ARB_map_buffer_range = GL_TRUE; 2297117f1b4Smrg ctx->Extensions.ARB_multitexture = GL_TRUE; 2304a49301eSmrg#if FEATURE_queryobj 2317117f1b4Smrg ctx->Extensions.ARB_occlusion_query = GL_TRUE; 2327117f1b4Smrg#endif 2337117f1b4Smrg ctx->Extensions.ARB_point_sprite = GL_TRUE; 2347117f1b4Smrg#if FEATURE_ARB_shader_objects 2357117f1b4Smrg ctx->Extensions.ARB_shader_objects = GL_TRUE; 2367117f1b4Smrg#endif 2377117f1b4Smrg#if FEATURE_ARB_shading_language_100 2387117f1b4Smrg ctx->Extensions.ARB_shading_language_100 = GL_TRUE; 2397117f1b4Smrg#endif 2407117f1b4Smrg#if FEATURE_ARB_shading_language_120 2417117f1b4Smrg ctx->Extensions.ARB_shading_language_120 = GL_TRUE; 2427117f1b4Smrg#endif 2437117f1b4Smrg ctx->Extensions.ARB_shadow = GL_TRUE; 2444a49301eSmrg ctx->Extensions.ARB_shadow_ambient = GL_TRUE; 2457117f1b4Smrg ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; 2467117f1b4Smrg ctx->Extensions.ARB_texture_cube_map = GL_TRUE; 2477117f1b4Smrg ctx->Extensions.ARB_texture_env_combine = GL_TRUE; 2487117f1b4Smrg ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; 2497117f1b4Smrg ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; 2507117f1b4Smrg /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/ 2517117f1b4Smrg ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; 2527117f1b4Smrg ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; 2534a49301eSmrg ctx->Extensions.ARB_vertex_array_object = GL_TRUE; 2547117f1b4Smrg#if FEATURE_ARB_vertex_program 2557117f1b4Smrg ctx->Extensions.ARB_vertex_program = GL_TRUE; 2567117f1b4Smrg#endif 2577117f1b4Smrg#if FEATURE_ARB_vertex_shader 2587117f1b4Smrg ctx->Extensions.ARB_vertex_shader = GL_TRUE; 2597117f1b4Smrg#endif 2607117f1b4Smrg#if FEATURE_ARB_vertex_buffer_object 2614a49301eSmrg /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ 2624a49301eSmrg#endif 2634a49301eSmrg#if FEATURE_ARB_sync 2644a49301eSmrg ctx->Extensions.ARB_sync = GL_TRUE; 2657117f1b4Smrg#endif 2667117f1b4Smrg ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; 2674a49301eSmrg ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE; 2687117f1b4Smrg#if FEATURE_ATI_fragment_shader 2697117f1b4Smrg ctx->Extensions.ATI_fragment_shader = GL_TRUE; 2707117f1b4Smrg#endif 2717117f1b4Smrg ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; 2727117f1b4Smrg ctx->Extensions.ATI_texture_mirror_once = GL_TRUE; 2737117f1b4Smrg ctx->Extensions.ATI_separate_stencil = GL_TRUE; 2747117f1b4Smrg ctx->Extensions.EXT_blend_color = GL_TRUE; 2757117f1b4Smrg ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; 2767117f1b4Smrg ctx->Extensions.EXT_blend_func_separate = GL_TRUE; 2777117f1b4Smrg ctx->Extensions.EXT_blend_logic_op = GL_TRUE; 2787117f1b4Smrg ctx->Extensions.EXT_blend_minmax = GL_TRUE; 2797117f1b4Smrg ctx->Extensions.EXT_blend_subtract = GL_TRUE; 2807117f1b4Smrg ctx->Extensions.EXT_convolution = GL_TRUE; 2817117f1b4Smrg ctx->Extensions.EXT_depth_bounds_test = GL_TRUE; 2827117f1b4Smrg ctx->Extensions.EXT_fog_coord = GL_TRUE; 2837117f1b4Smrg#if FEATURE_EXT_framebuffer_object 2847117f1b4Smrg ctx->Extensions.EXT_framebuffer_object = GL_TRUE; 2857117f1b4Smrg#endif 2867117f1b4Smrg#if FEATURE_EXT_framebuffer_blit 2877117f1b4Smrg ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; 2884a49301eSmrg#endif 2894a49301eSmrg#if FEATURE_ARB_framebuffer_object 2904a49301eSmrg ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; 2917117f1b4Smrg#endif 2927117f1b4Smrg ctx->Extensions.EXT_histogram = GL_TRUE; 2934a49301eSmrg /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ 2947117f1b4Smrg ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; 2957117f1b4Smrg ctx->Extensions.EXT_paletted_texture = GL_TRUE; 2967117f1b4Smrg#if FEATURE_EXT_pixel_buffer_object 2977117f1b4Smrg ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; 2987117f1b4Smrg#endif 2997117f1b4Smrg ctx->Extensions.EXT_point_parameters = GL_TRUE; 3004a49301eSmrg ctx->Extensions.EXT_provoking_vertex = GL_TRUE; 3017117f1b4Smrg ctx->Extensions.EXT_shadow_funcs = GL_TRUE; 3027117f1b4Smrg ctx->Extensions.EXT_secondary_color = GL_TRUE; 3037117f1b4Smrg ctx->Extensions.EXT_shared_texture_palette = GL_TRUE; 3047117f1b4Smrg ctx->Extensions.EXT_stencil_wrap = GL_TRUE; 305c1f859d4Smrg ctx->Extensions.EXT_stencil_two_side = GL_TRUE; 3067117f1b4Smrg ctx->Extensions.EXT_texture_env_add = GL_TRUE; 3077117f1b4Smrg ctx->Extensions.EXT_texture_env_combine = GL_TRUE; 3087117f1b4Smrg ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; 3097117f1b4Smrg ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE; 3107117f1b4Smrg ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; 3117117f1b4Smrg#if FEATURE_EXT_texture_sRGB 3127117f1b4Smrg ctx->Extensions.EXT_texture_sRGB = GL_TRUE; 3137117f1b4Smrg#endif 3144a49301eSmrg ctx->Extensions.EXT_texture_swizzle = GL_TRUE; 3154a49301eSmrg ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; 3164a49301eSmrg /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/ 3177117f1b4Smrg ctx->Extensions.MESA_pack_invert = GL_TRUE; 3187117f1b4Smrg ctx->Extensions.MESA_resize_buffers = GL_TRUE; 319c1f859d4Smrg ctx->Extensions.MESA_texture_array = GL_TRUE; 3207117f1b4Smrg ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; 3217117f1b4Smrg ctx->Extensions.NV_blend_square = GL_TRUE; 3227117f1b4Smrg /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/ 3237117f1b4Smrg ctx->Extensions.NV_point_sprite = GL_TRUE; 3244a49301eSmrg ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; 3257117f1b4Smrg ctx->Extensions.NV_texture_rectangle = GL_TRUE; 3267117f1b4Smrg /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/ 3277117f1b4Smrg#if FEATURE_NV_vertex_program 3287117f1b4Smrg ctx->Extensions.NV_vertex_program = GL_TRUE; 3297117f1b4Smrg ctx->Extensions.NV_vertex_program1_1 = GL_TRUE; 3307117f1b4Smrg#endif 3317117f1b4Smrg#if FEATURE_NV_fragment_program 3327117f1b4Smrg ctx->Extensions.NV_fragment_program = GL_TRUE; 3334a49301eSmrg#endif 3344a49301eSmrg#if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program 3354a49301eSmrg ctx->Extensions.NV_fragment_program_option = GL_TRUE; 3367117f1b4Smrg#endif 3377117f1b4Smrg ctx->Extensions.SGI_color_matrix = GL_TRUE; 3387117f1b4Smrg ctx->Extensions.SGI_color_table = GL_TRUE; 3397117f1b4Smrg ctx->Extensions.SGI_texture_color_table = GL_TRUE; 3407117f1b4Smrg ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; 3417117f1b4Smrg ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE; 3427117f1b4Smrg#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program 3437117f1b4Smrg ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; 3447117f1b4Smrg#endif 345c1f859d4Smrg#if FEATURE_texture_fxt1 346c1f859d4Smrg _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1"); 347c1f859d4Smrg#endif 348c1f859d4Smrg#if FEATURE_texture_s3tc 349c1f859d4Smrg if (ctx->Mesa_DXTn) { 350c1f859d4Smrg _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); 351c1f859d4Smrg _mesa_enable_extension(ctx, "GL_S3_s3tc"); 352c1f859d4Smrg } 353c1f859d4Smrg#endif 3547117f1b4Smrg} 3557117f1b4Smrg 3567117f1b4Smrg 3577117f1b4Smrg/** 3587117f1b4Smrg * Enable GL_ARB_imaging and all the EXT extensions that are subsets of it. 3597117f1b4Smrg */ 3607117f1b4Smrgvoid 3617117f1b4Smrg_mesa_enable_imaging_extensions(GLcontext *ctx) 3627117f1b4Smrg{ 3637117f1b4Smrg ctx->Extensions.ARB_imaging = GL_TRUE; 3647117f1b4Smrg ctx->Extensions.EXT_blend_color = GL_TRUE; 365c1f859d4Smrg ctx->Extensions.EXT_blend_logic_op = GL_TRUE; 3667117f1b4Smrg ctx->Extensions.EXT_blend_minmax = GL_TRUE; 3677117f1b4Smrg ctx->Extensions.EXT_blend_subtract = GL_TRUE; 3687117f1b4Smrg ctx->Extensions.EXT_convolution = GL_TRUE; 3697117f1b4Smrg ctx->Extensions.EXT_histogram = GL_TRUE; 3707117f1b4Smrg ctx->Extensions.SGI_color_matrix = GL_TRUE; 3717117f1b4Smrg ctx->Extensions.SGI_color_table = GL_TRUE; 3727117f1b4Smrg} 3737117f1b4Smrg 3747117f1b4Smrg 3757117f1b4Smrg 3767117f1b4Smrg/** 3777117f1b4Smrg * Enable all OpenGL 1.3 features and extensions. 3787117f1b4Smrg * A convenience function to be called by drivers. 3797117f1b4Smrg */ 3807117f1b4Smrgvoid 3817117f1b4Smrg_mesa_enable_1_3_extensions(GLcontext *ctx) 3827117f1b4Smrg{ 3834a49301eSmrg /*ctx->Extensions.ARB_multisample = GL_TRUE;*/ 3847117f1b4Smrg ctx->Extensions.ARB_multitexture = GL_TRUE; 3857117f1b4Smrg ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; 3864a49301eSmrg /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/ 3877117f1b4Smrg ctx->Extensions.ARB_texture_cube_map = GL_TRUE; 3887117f1b4Smrg ctx->Extensions.ARB_texture_env_combine = GL_TRUE; 3897117f1b4Smrg ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; 3907117f1b4Smrg ctx->Extensions.EXT_texture_env_add = GL_TRUE; 3917117f1b4Smrg /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/ 3927117f1b4Smrg} 3937117f1b4Smrg 3947117f1b4Smrg 3957117f1b4Smrg 3967117f1b4Smrg/** 3977117f1b4Smrg * Enable all OpenGL 1.4 features and extensions. 3987117f1b4Smrg * A convenience function to be called by drivers. 3997117f1b4Smrg */ 4007117f1b4Smrgvoid 4017117f1b4Smrg_mesa_enable_1_4_extensions(GLcontext *ctx) 4027117f1b4Smrg{ 4037117f1b4Smrg ctx->Extensions.ARB_depth_texture = GL_TRUE; 4047117f1b4Smrg ctx->Extensions.ARB_shadow = GL_TRUE; 4057117f1b4Smrg ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; 4067117f1b4Smrg ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; 4077117f1b4Smrg ctx->Extensions.ARB_window_pos = GL_TRUE; 4087117f1b4Smrg ctx->Extensions.EXT_blend_color = GL_TRUE; 4097117f1b4Smrg ctx->Extensions.EXT_blend_func_separate = GL_TRUE; 4107117f1b4Smrg ctx->Extensions.EXT_blend_minmax = GL_TRUE; 4117117f1b4Smrg ctx->Extensions.EXT_blend_subtract = GL_TRUE; 4127117f1b4Smrg ctx->Extensions.EXT_fog_coord = GL_TRUE; 4134a49301eSmrg /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ 4147117f1b4Smrg ctx->Extensions.EXT_point_parameters = GL_TRUE; 4157117f1b4Smrg ctx->Extensions.EXT_secondary_color = GL_TRUE; 4167117f1b4Smrg ctx->Extensions.EXT_stencil_wrap = GL_TRUE; 4177117f1b4Smrg ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; 4187117f1b4Smrg ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; 4197117f1b4Smrg} 4207117f1b4Smrg 4217117f1b4Smrg 4227117f1b4Smrg/** 4237117f1b4Smrg * Enable all OpenGL 1.5 features and extensions. 4247117f1b4Smrg * A convenience function to be called by drivers. 4257117f1b4Smrg */ 4267117f1b4Smrgvoid 4277117f1b4Smrg_mesa_enable_1_5_extensions(GLcontext *ctx) 4287117f1b4Smrg{ 4297117f1b4Smrg ctx->Extensions.ARB_occlusion_query = GL_TRUE; 4304a49301eSmrg /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ 4317117f1b4Smrg ctx->Extensions.EXT_shadow_funcs = GL_TRUE; 4327117f1b4Smrg} 4337117f1b4Smrg 4347117f1b4Smrg 4357117f1b4Smrg/** 4367117f1b4Smrg * Enable all OpenGL 2.0 features and extensions. 4377117f1b4Smrg * A convenience function to be called by drivers. 4387117f1b4Smrg */ 4397117f1b4Smrgvoid 4407117f1b4Smrg_mesa_enable_2_0_extensions(GLcontext *ctx) 4417117f1b4Smrg{ 4424a49301eSmrg /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ 4437117f1b4Smrg#if FEATURE_ARB_fragment_shader 4447117f1b4Smrg ctx->Extensions.ARB_fragment_shader = GL_TRUE; 4457117f1b4Smrg#endif 4467117f1b4Smrg ctx->Extensions.ARB_point_sprite = GL_TRUE; 4474a49301eSmrg ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; 4487117f1b4Smrg ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; 4497117f1b4Smrg#if FEATURE_ARB_shader_objects 4507117f1b4Smrg ctx->Extensions.ARB_shader_objects = GL_TRUE; 4517117f1b4Smrg#endif 4527117f1b4Smrg#if FEATURE_ARB_shading_language_100 4537117f1b4Smrg ctx->Extensions.ARB_shading_language_100 = GL_TRUE; 4547117f1b4Smrg#endif 455c1f859d4Smrg ctx->Extensions.EXT_stencil_two_side = GL_TRUE; 4567117f1b4Smrg#if FEATURE_ARB_vertex_shader 4577117f1b4Smrg ctx->Extensions.ARB_vertex_shader = GL_TRUE; 4587117f1b4Smrg#endif 4597117f1b4Smrg} 4607117f1b4Smrg 4617117f1b4Smrg 4627117f1b4Smrg/** 4637117f1b4Smrg * Enable all OpenGL 2.1 features and extensions. 4647117f1b4Smrg * A convenience function to be called by drivers. 4657117f1b4Smrg */ 4667117f1b4Smrgvoid 4677117f1b4Smrg_mesa_enable_2_1_extensions(GLcontext *ctx) 4687117f1b4Smrg{ 4697117f1b4Smrg#if FEATURE_EXT_pixel_buffer_object 4707117f1b4Smrg ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; 4717117f1b4Smrg#endif 4727117f1b4Smrg#if FEATURE_EXT_texture_sRGB 4737117f1b4Smrg ctx->Extensions.EXT_texture_sRGB = GL_TRUE; 4747117f1b4Smrg#endif 4757117f1b4Smrg#ifdef FEATURE_ARB_shading_language_120 4767117f1b4Smrg ctx->Extensions.ARB_shading_language_120 = GL_TRUE; 4777117f1b4Smrg#endif 4787117f1b4Smrg} 4797117f1b4Smrg 4807117f1b4Smrg 4817117f1b4Smrg 4827117f1b4Smrg/** 4837117f1b4Smrg * Either enable or disable the named extension. 4844a49301eSmrg * \return GL_TRUE for success, GL_FALSE if invalid extension name 4857117f1b4Smrg */ 4864a49301eSmrgstatic GLboolean 4877117f1b4Smrgset_extension( GLcontext *ctx, const char *name, GLboolean state ) 4887117f1b4Smrg{ 4897117f1b4Smrg GLboolean *base = (GLboolean *) &ctx->Extensions; 4907117f1b4Smrg GLuint i; 4917117f1b4Smrg 4927117f1b4Smrg if (ctx->Extensions.String) { 4937117f1b4Smrg /* The string was already queried - can't change it now! */ 4947117f1b4Smrg _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name); 4954a49301eSmrg return GL_FALSE; 4967117f1b4Smrg } 4977117f1b4Smrg 4987117f1b4Smrg for (i = 0 ; i < Elements(default_extensions) ; i++) { 4997117f1b4Smrg if (_mesa_strcmp(default_extensions[i].name, name) == 0) { 5007117f1b4Smrg if (default_extensions[i].flag_offset) { 5017117f1b4Smrg GLboolean *enabled = base + default_extensions[i].flag_offset; 5027117f1b4Smrg *enabled = state; 5037117f1b4Smrg } 5044a49301eSmrg return GL_TRUE; 5057117f1b4Smrg } 5067117f1b4Smrg } 5074a49301eSmrg return GL_FALSE; 5087117f1b4Smrg} 5097117f1b4Smrg 5107117f1b4Smrg 5117117f1b4Smrg/** 5127117f1b4Smrg * Enable the named extension. 5137117f1b4Smrg * Typically called by drivers. 5147117f1b4Smrg */ 5157117f1b4Smrgvoid 5167117f1b4Smrg_mesa_enable_extension( GLcontext *ctx, const char *name ) 5177117f1b4Smrg{ 5184a49301eSmrg if (!set_extension(ctx, name, GL_TRUE)) 5194a49301eSmrg _mesa_problem(ctx, "Trying to enable unknown extension: %s", name); 5207117f1b4Smrg} 5217117f1b4Smrg 5227117f1b4Smrg 5237117f1b4Smrg/** 5247117f1b4Smrg * Disable the named extension. 5257117f1b4Smrg * XXX is this really needed??? 5267117f1b4Smrg */ 5277117f1b4Smrgvoid 5287117f1b4Smrg_mesa_disable_extension( GLcontext *ctx, const char *name ) 5297117f1b4Smrg{ 5304a49301eSmrg if (!set_extension(ctx, name, GL_FALSE)) 5314a49301eSmrg _mesa_problem(ctx, "Trying to disable unknown extension: %s", name); 5327117f1b4Smrg} 5337117f1b4Smrg 5347117f1b4Smrg 5357117f1b4Smrg/** 5367117f1b4Smrg * Test if the named extension is enabled in this context. 5377117f1b4Smrg */ 5387117f1b4SmrgGLboolean 5397117f1b4Smrg_mesa_extension_is_enabled( GLcontext *ctx, const char *name ) 5407117f1b4Smrg{ 5417117f1b4Smrg const GLboolean *base = (const GLboolean *) &ctx->Extensions; 5427117f1b4Smrg GLuint i; 5437117f1b4Smrg 5447117f1b4Smrg for (i = 0 ; i < Elements(default_extensions) ; i++) { 5457117f1b4Smrg if (_mesa_strcmp(default_extensions[i].name, name) == 0) { 5467117f1b4Smrg if (!default_extensions[i].flag_offset) 5477117f1b4Smrg return GL_TRUE; 5487117f1b4Smrg return *(base + default_extensions[i].flag_offset); 5497117f1b4Smrg } 5507117f1b4Smrg } 5517117f1b4Smrg return GL_FALSE; 5527117f1b4Smrg} 5537117f1b4Smrg 5547117f1b4Smrg 5554a49301eSmrg/** 5564a49301eSmrg * Append string 'b' onto string 'a'. Free 'a' and return new string. 5574a49301eSmrg */ 5584a49301eSmrgstatic char * 5594a49301eSmrgappend(const char *a, const char *b) 5604a49301eSmrg{ 5614a49301eSmrg const GLuint aLen = a ? _mesa_strlen(a) : 0; 5624a49301eSmrg const GLuint bLen = b ? _mesa_strlen(b) : 0; 5634a49301eSmrg char *s = _mesa_calloc(aLen + bLen + 1); 5644a49301eSmrg if (s) { 5654a49301eSmrg if (a) 5664a49301eSmrg _mesa_memcpy(s, a, aLen); 5674a49301eSmrg if (b) 5684a49301eSmrg _mesa_memcpy(s + aLen, b, bLen); 5694a49301eSmrg s[aLen + bLen] = '\0'; 5704a49301eSmrg } 5714a49301eSmrg if (a) 5724a49301eSmrg _mesa_free((void *) a); 5734a49301eSmrg return s; 5744a49301eSmrg} 5754a49301eSmrg 5764a49301eSmrg 5774a49301eSmrg/** 5784a49301eSmrg * Check the MESA_EXTENSION_OVERRIDE env var. 5794a49301eSmrg * For extension names that are recognized, turn them on. For extension 5804a49301eSmrg * names that are recognized and prefixed with '-', turn them off. 5814a49301eSmrg * Return a string of the unknown/leftover names. 5824a49301eSmrg */ 5834a49301eSmrgstatic const char * 5844a49301eSmrgget_extension_override( GLcontext *ctx ) 5854a49301eSmrg{ 5864a49301eSmrg const char *envExt = _mesa_getenv("MESA_EXTENSION_OVERRIDE"); 5874a49301eSmrg char *extraExt = NULL; 5884a49301eSmrg char ext[1000]; 5894a49301eSmrg GLuint extLen = 0; 5904a49301eSmrg GLuint i; 5914a49301eSmrg GLboolean disableExt = GL_FALSE; 5924a49301eSmrg 5934a49301eSmrg if (!envExt) 5944a49301eSmrg return NULL; 5954a49301eSmrg 5964a49301eSmrg for (i = 0; ; i++) { 5974a49301eSmrg if (envExt[i] == '\0' || envExt[i] == ' ') { 5984a49301eSmrg /* terminate/process 'ext' if extLen > 0 */ 5994a49301eSmrg if (extLen > 0) { 6004a49301eSmrg assert(extLen < sizeof(ext)); 6014a49301eSmrg /* enable extension named by 'ext' */ 6024a49301eSmrg ext[extLen] = 0; 6034a49301eSmrg if (!set_extension(ctx, ext, !disableExt)) { 6044a49301eSmrg /* unknown extension name, append it to extraExt */ 6054a49301eSmrg if (extraExt) { 6064a49301eSmrg extraExt = append(extraExt, " "); 6074a49301eSmrg } 6084a49301eSmrg extraExt = append(extraExt, ext); 6094a49301eSmrg } 6104a49301eSmrg extLen = 0; 6114a49301eSmrg disableExt = GL_FALSE; 6124a49301eSmrg } 6134a49301eSmrg if (envExt[i] == '\0') 6144a49301eSmrg break; 6154a49301eSmrg } 6164a49301eSmrg else if (envExt[i] == '-') { 6174a49301eSmrg disableExt = GL_TRUE; 6184a49301eSmrg } 6194a49301eSmrg else { 6204a49301eSmrg /* accumulate this non-space character */ 6214a49301eSmrg ext[extLen++] = envExt[i]; 6224a49301eSmrg } 6234a49301eSmrg } 6244a49301eSmrg 6254a49301eSmrg return extraExt; 6264a49301eSmrg} 6274a49301eSmrg 6284a49301eSmrg 6297117f1b4Smrg/** 6307117f1b4Smrg * Run through the default_extensions array above and set the 6317117f1b4Smrg * ctx->Extensions.ARB/EXT_* flags accordingly. 6327117f1b4Smrg * To be called during context initialization. 6337117f1b4Smrg */ 6347117f1b4Smrgvoid 6357117f1b4Smrg_mesa_init_extensions( GLcontext *ctx ) 6367117f1b4Smrg{ 6377117f1b4Smrg GLboolean *base = (GLboolean *) &ctx->Extensions; 6387117f1b4Smrg GLuint i; 6397117f1b4Smrg 6407117f1b4Smrg for (i = 0 ; i < Elements(default_extensions) ; i++) { 6417117f1b4Smrg if (default_extensions[i].enabled && 6427117f1b4Smrg default_extensions[i].flag_offset) { 6437117f1b4Smrg *(base + default_extensions[i].flag_offset) = GL_TRUE; 6447117f1b4Smrg } 6457117f1b4Smrg } 6467117f1b4Smrg} 6477117f1b4Smrg 6487117f1b4Smrg 6497117f1b4Smrg/** 6507117f1b4Smrg * Construct the GL_EXTENSIONS string. Called the first time that 6517117f1b4Smrg * glGetString(GL_EXTENSIONS) is called. 6527117f1b4Smrg */ 6537117f1b4SmrgGLubyte * 6547117f1b4Smrg_mesa_make_extension_string( GLcontext *ctx ) 6557117f1b4Smrg{ 6567117f1b4Smrg const GLboolean *base = (const GLboolean *) &ctx->Extensions; 6574a49301eSmrg const char *extraExt = get_extension_override(ctx); 6587117f1b4Smrg GLuint extStrLen = 0; 6594a49301eSmrg char *s; 6607117f1b4Smrg GLuint i; 6617117f1b4Smrg 6627117f1b4Smrg /* first, compute length of the extension string */ 6637117f1b4Smrg for (i = 0 ; i < Elements(default_extensions) ; i++) { 6647117f1b4Smrg if (!default_extensions[i].flag_offset || 6657117f1b4Smrg *(base + default_extensions[i].flag_offset)) { 6667117f1b4Smrg extStrLen += (GLuint)_mesa_strlen(default_extensions[i].name) + 1; 6677117f1b4Smrg } 6687117f1b4Smrg } 6694a49301eSmrg 6704a49301eSmrg if (extraExt) 6714a49301eSmrg extStrLen += _mesa_strlen(extraExt) + 1; /* +1 for space */ 6724a49301eSmrg 6734a49301eSmrg /* allocate the extension string */ 6744a49301eSmrg s = (char *) _mesa_malloc(extStrLen); 6754a49301eSmrg if (!s) 6764a49301eSmrg return NULL; 6777117f1b4Smrg 6787117f1b4Smrg /* second, build the extension string */ 6797117f1b4Smrg extStrLen = 0; 6807117f1b4Smrg for (i = 0 ; i < Elements(default_extensions) ; i++) { 6817117f1b4Smrg if (!default_extensions[i].flag_offset || 6827117f1b4Smrg *(base + default_extensions[i].flag_offset)) { 6837117f1b4Smrg GLuint len = (GLuint)_mesa_strlen(default_extensions[i].name); 6847117f1b4Smrg _mesa_memcpy(s + extStrLen, default_extensions[i].name, len); 6857117f1b4Smrg extStrLen += len; 6864a49301eSmrg s[extStrLen] = ' '; 6877117f1b4Smrg extStrLen++; 6887117f1b4Smrg } 6897117f1b4Smrg } 6907117f1b4Smrg ASSERT(extStrLen > 0); 6917117f1b4Smrg 6924a49301eSmrg s[extStrLen - 1] = 0; /* -1 to overwrite trailing the ' ' */ 6937117f1b4Smrg 6944a49301eSmrg if (extraExt) { 6954a49301eSmrg s = append(s, " "); 6964a49301eSmrg s = append(s, extraExt); 6974a49301eSmrg } 6984a49301eSmrg 6994a49301eSmrg return (GLubyte *) s; 7007117f1b4Smrg} 701