extensions.c revision cdc920a0
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 { OFF, "GL_ARB_copy_buffer", F(ARB_copy_buffer) }, 497117f1b4Smrg { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) }, 504a49301eSmrg { OFF, "GL_ARB_depth_clamp", F(ARB_depth_clamp) }, 514a49301eSmrg { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) }, 524a49301eSmrg { OFF, "GL_ARB_draw_elements_base_vertex", F(ARB_draw_elements_base_vertex) }, 53cdc920a0Smrg { OFF, "GL_ARB_fragment_coord_conventions", F(ARB_fragment_coord_conventions) }, 547117f1b4Smrg { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) }, 55c1f859d4Smrg { OFF, "GL_ARB_fragment_program_shadow", F(ARB_fragment_program_shadow) }, 567117f1b4Smrg { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) }, 574a49301eSmrg { OFF, "GL_ARB_framebuffer_object", F(ARB_framebuffer_object) }, 587117f1b4Smrg { OFF, "GL_ARB_half_float_pixel", F(ARB_half_float_pixel) }, 59cdc920a0Smrg { OFF, "GL_ARB_half_float_vertex", F(ARB_half_float_vertex) }, 607117f1b4Smrg { OFF, "GL_ARB_imaging", F(ARB_imaging) }, 614a49301eSmrg { OFF, "GL_ARB_map_buffer_range", F(ARB_map_buffer_range) }, 624a49301eSmrg { ON, "GL_ARB_multisample", F(ARB_multisample) }, 637117f1b4Smrg { OFF, "GL_ARB_multitexture", F(ARB_multitexture) }, 647117f1b4Smrg { OFF, "GL_ARB_occlusion_query", F(ARB_occlusion_query) }, 657117f1b4Smrg { OFF, "GL_ARB_pixel_buffer_object", F(EXT_pixel_buffer_object) }, 667117f1b4Smrg { OFF, "GL_ARB_point_parameters", F(EXT_point_parameters) }, 677117f1b4Smrg { OFF, "GL_ARB_point_sprite", F(ARB_point_sprite) }, 684a49301eSmrg { OFF, "GL_ARB_provoking_vertex", F(EXT_provoking_vertex) }, 694a49301eSmrg { OFF, "GL_ARB_seamless_cube_map", F(ARB_seamless_cube_map) }, 707117f1b4Smrg { OFF, "GL_ARB_shader_objects", F(ARB_shader_objects) }, 717117f1b4Smrg { OFF, "GL_ARB_shading_language_100", F(ARB_shading_language_100) }, 727117f1b4Smrg { OFF, "GL_ARB_shading_language_120", F(ARB_shading_language_120) }, 737117f1b4Smrg { OFF, "GL_ARB_shadow", F(ARB_shadow) }, 744a49301eSmrg { OFF, "GL_ARB_shadow_ambient", F(ARB_shadow_ambient) }, 754a49301eSmrg { OFF, "GL_ARB_sync", F(ARB_sync) }, 767117f1b4Smrg { OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) }, 774a49301eSmrg { ON, "GL_ARB_texture_compression", F(ARB_texture_compression) }, 787117f1b4Smrg { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) }, 797117f1b4Smrg { OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) }, 807117f1b4Smrg { OFF, "GL_ARB_texture_env_combine", F(ARB_texture_env_combine) }, 817117f1b4Smrg { OFF, "GL_ARB_texture_env_crossbar", F(ARB_texture_env_crossbar) }, 827117f1b4Smrg { OFF, "GL_ARB_texture_env_dot3", F(ARB_texture_env_dot3) }, 837117f1b4Smrg { OFF, "GL_MESAX_texture_float", F(ARB_texture_float) }, 847117f1b4Smrg { OFF, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)}, 857117f1b4Smrg { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)}, 867117f1b4Smrg { OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) }, 877117f1b4Smrg { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) }, 884a49301eSmrg { OFF, "GL_ARB_vertex_array_bgra", F(EXT_vertex_array_bgra) }, 894a49301eSmrg { OFF, "GL_ARB_vertex_array_object", F(ARB_vertex_array_object) }, 904a49301eSmrg { ON, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) }, 917117f1b4Smrg { OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) }, 927117f1b4Smrg { OFF, "GL_ARB_vertex_shader", F(ARB_vertex_shader) }, 937117f1b4Smrg { ON, "GL_ARB_window_pos", F(ARB_window_pos) }, 947117f1b4Smrg { ON, "GL_EXT_abgr", F(EXT_abgr) }, 957117f1b4Smrg { ON, "GL_EXT_bgra", F(EXT_bgra) }, 967117f1b4Smrg { OFF, "GL_EXT_blend_color", F(EXT_blend_color) }, 977117f1b4Smrg { OFF, "GL_EXT_blend_equation_separate", F(EXT_blend_equation_separate) }, 987117f1b4Smrg { OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) }, 997117f1b4Smrg { OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) }, 1007117f1b4Smrg { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) }, 1017117f1b4Smrg { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) }, 1024a49301eSmrg { OFF, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) }, 1037117f1b4Smrg { OFF, "GL_EXT_cull_vertex", F(EXT_cull_vertex) }, 104cdc920a0Smrg { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) }, 1057117f1b4Smrg { OFF, "GL_EXT_convolution", F(EXT_convolution) }, 1067117f1b4Smrg { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) }, 1077117f1b4Smrg { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) }, 108cdc920a0Smrg { OFF, "GL_EXT_draw_buffers2", F(EXT_draw_buffers2) }, 1097117f1b4Smrg { ON, "GL_EXT_draw_range_elements", F(EXT_draw_range_elements) }, 1107117f1b4Smrg { OFF, "GL_EXT_framebuffer_blit", F(EXT_framebuffer_blit) }, 1114a49301eSmrg { OFF, "GL_EXT_framebuffer_multisample", F(EXT_framebuffer_multisample) }, 1124a49301eSmrg { OFF, "GL_EXT_framebuffer_object", F(EXT_framebuffer_object) }, 1137117f1b4Smrg { OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) }, 1147117f1b4Smrg { OFF, "GL_EXT_gpu_program_parameters", F(EXT_gpu_program_parameters) }, 1157117f1b4Smrg { OFF, "GL_EXT_histogram", F(EXT_histogram) }, 1164a49301eSmrg { ON, "GL_EXT_multi_draw_arrays", F(EXT_multi_draw_arrays) }, 1177117f1b4Smrg { OFF, "GL_EXT_packed_depth_stencil", F(EXT_packed_depth_stencil) }, 1187117f1b4Smrg { ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) }, 1197117f1b4Smrg { OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) }, 1207117f1b4Smrg { OFF, "GL_EXT_pixel_buffer_object", F(EXT_pixel_buffer_object) }, 1217117f1b4Smrg { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) }, 1227117f1b4Smrg { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) }, 1234a49301eSmrg { OFF, "GL_EXT_provoking_vertex", F(EXT_provoking_vertex) }, 1247117f1b4Smrg { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) }, 1257117f1b4Smrg { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) }, 1267117f1b4Smrg { ON, "GL_EXT_separate_specular_color", F(EXT_separate_specular_color) }, 1277117f1b4Smrg { OFF, "GL_EXT_shadow_funcs", F(EXT_shadow_funcs) }, 1287117f1b4Smrg { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) }, 1297117f1b4Smrg { OFF, "GL_EXT_stencil_two_side", F(EXT_stencil_two_side) }, 1307117f1b4Smrg { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) }, 1317117f1b4Smrg { ON, "GL_EXT_subtexture", F(EXT_subtexture) }, 1327117f1b4Smrg { ON, "GL_EXT_texture", F(EXT_texture) }, 1337117f1b4Smrg { ON, "GL_EXT_texture3D", F(EXT_texture3D) }, 134cdc920a0Smrg { OFF, "GL_EXT_texture_array", F(EXT_texture_array) }, 135cdc920a0Smrg { OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) }, 1364a49301eSmrg { OFF, "GL_EXT_texture_cube_map", F(ARB_texture_cube_map) }, 1377117f1b4Smrg { ON, "GL_EXT_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, 138cdc920a0Smrg { OFF, "GL_EXT_texture_env_add", F(EXT_texture_env_add) }, 1397117f1b4Smrg { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) }, 1407117f1b4Smrg { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) }, 1417117f1b4Smrg { OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) }, 1427117f1b4Smrg { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) }, 1437117f1b4Smrg { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) }, 1447117f1b4Smrg { ON, "GL_EXT_texture_object", F(EXT_texture_object) }, 1457117f1b4Smrg { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) }, 1467117f1b4Smrg { OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) }, 1474a49301eSmrg { OFF, "GL_EXT_texture_swizzle", F(EXT_texture_swizzle) }, 1487117f1b4Smrg { OFF, "GL_EXT_timer_query", F(EXT_timer_query) }, 1497117f1b4Smrg { ON, "GL_EXT_vertex_array", F(EXT_vertex_array) }, 1504a49301eSmrg { OFF, "GL_EXT_vertex_array_bgra", F(EXT_vertex_array_bgra) }, 1517117f1b4Smrg { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) }, 1527117f1b4Smrg { OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) }, 1537117f1b4Smrg { OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) }, 1547117f1b4Smrg { ON, "GL_APPLE_packed_pixels", F(APPLE_packed_pixels) }, 1557117f1b4Smrg { OFF, "GL_APPLE_vertex_array_object", F(APPLE_vertex_array_object) }, 156cdc920a0Smrg { OFF, "GL_APPLE_object_purgeable", F(APPLE_object_purgeable) }, 1577117f1b4Smrg { OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate) }, 1584a49301eSmrg { OFF, "GL_ATI_envmap_bumpmap", F(ATI_envmap_bumpmap) }, 1597117f1b4Smrg { OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)}, 1607117f1b4Smrg { OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)}, 1617117f1b4Smrg { OFF, "GL_ATI_fragment_shader", F(ATI_fragment_shader)}, 1627117f1b4Smrg { OFF, "GL_ATI_separate_stencil", F(ATI_separate_stencil)}, 1634a49301eSmrg { ON, "GL_IBM_multimode_draw_arrays", F(IBM_multimode_draw_arrays) }, 1647117f1b4Smrg { ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) }, 1657117f1b4Smrg { OFF, "GL_IBM_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)}, 1667117f1b4Smrg { OFF, "GL_INGR_blend_func_separate", F(EXT_blend_func_separate) }, 1677117f1b4Smrg { OFF, "GL_MESA_pack_invert", F(MESA_pack_invert) }, 1687117f1b4Smrg { OFF, "GL_MESA_packed_depth_stencil", F(MESA_packed_depth_stencil) }, 1697117f1b4Smrg { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) }, 170c1f859d4Smrg { OFF, "GL_MESA_texture_array", F(MESA_texture_array) }, 1714a49301eSmrg { OFF, "GL_MESA_texture_signed_rgba", F(MESA_texture_signed_rgba) }, 1727117f1b4Smrg { OFF, "GL_MESA_ycbcr_texture", F(MESA_ycbcr_texture) }, 1737117f1b4Smrg { ON, "GL_MESA_window_pos", F(ARB_window_pos) }, 1747117f1b4Smrg { OFF, "GL_NV_blend_square", F(NV_blend_square) }, 175cdc920a0Smrg { OFF, "GL_NV_conditional_render", F(NV_conditional_render) }, 1764a49301eSmrg { OFF, "GL_NV_depth_clamp", F(ARB_depth_clamp) }, 1777117f1b4Smrg { OFF, "GL_NV_fragment_program", F(NV_fragment_program) }, 1784a49301eSmrg { OFF, "GL_NV_fragment_program_option", F(NV_fragment_program_option) }, 1797117f1b4Smrg { ON, "GL_NV_light_max_exponent", F(NV_light_max_exponent) }, 1804a49301eSmrg { OFF, "GL_NV_packed_depth_stencil", F(EXT_packed_depth_stencil) }, 1817117f1b4Smrg { OFF, "GL_NV_point_sprite", F(NV_point_sprite) }, 1824a49301eSmrg { OFF, "GL_NV_texture_env_combine4", F(NV_texture_env_combine4) }, 1837117f1b4Smrg { OFF, "GL_NV_texture_rectangle", F(NV_texture_rectangle) }, 1847117f1b4Smrg { ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) }, 1857117f1b4Smrg { OFF, "GL_NV_vertex_program", F(NV_vertex_program) }, 1867117f1b4Smrg { OFF, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1) }, 1877117f1b4Smrg { ON, "GL_OES_read_format", F(OES_read_format) }, 1887117f1b4Smrg { OFF, "GL_SGI_color_matrix", F(SGI_color_matrix) }, 1897117f1b4Smrg { OFF, "GL_SGI_color_table", F(SGI_color_table) }, 1907117f1b4Smrg { OFF, "GL_SGI_texture_color_table", F(SGI_texture_color_table) }, 1917117f1b4Smrg { OFF, "GL_SGIS_generate_mipmap", F(SGIS_generate_mipmap) }, 1927117f1b4Smrg { OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) }, 1937117f1b4Smrg { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, 1947117f1b4Smrg { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) }, 1954a49301eSmrg { ON, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) }, 1967117f1b4Smrg { OFF, "GL_S3_s3tc", F(S3_s3tc) }, 197cdc920a0Smrg#if FEATURE_OES_draw_texture 198cdc920a0Smrg { OFF, "GL_OES_draw_texture", F(OES_draw_texture) }, 199cdc920a0Smrg#endif /* FEATURE_OES_draw_texture */ 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; 216cdc920a0Smrg ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; 2177117f1b4Smrg#if FEATURE_ARB_fragment_program 2187117f1b4Smrg ctx->Extensions.ARB_fragment_program = GL_TRUE; 219c1f859d4Smrg ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE; 2207117f1b4Smrg#endif 2217117f1b4Smrg#if FEATURE_ARB_fragment_shader 2227117f1b4Smrg ctx->Extensions.ARB_fragment_shader = GL_TRUE; 2234a49301eSmrg#endif 2244a49301eSmrg#if FEATURE_ARB_framebuffer_object 2254a49301eSmrg ctx->Extensions.ARB_framebuffer_object = GL_TRUE; 2267117f1b4Smrg#endif 2277117f1b4Smrg ctx->Extensions.ARB_half_float_pixel = GL_TRUE; 228cdc920a0Smrg ctx->Extensions.ARB_half_float_vertex = GL_TRUE; 2297117f1b4Smrg ctx->Extensions.ARB_imaging = GL_TRUE; 2304a49301eSmrg ctx->Extensions.ARB_map_buffer_range = GL_TRUE; 2317117f1b4Smrg ctx->Extensions.ARB_multitexture = GL_TRUE; 2324a49301eSmrg#if FEATURE_queryobj 2337117f1b4Smrg ctx->Extensions.ARB_occlusion_query = GL_TRUE; 2347117f1b4Smrg#endif 2357117f1b4Smrg ctx->Extensions.ARB_point_sprite = GL_TRUE; 2367117f1b4Smrg#if FEATURE_ARB_shader_objects 2377117f1b4Smrg ctx->Extensions.ARB_shader_objects = GL_TRUE; 2387117f1b4Smrg#endif 2397117f1b4Smrg#if FEATURE_ARB_shading_language_100 2407117f1b4Smrg ctx->Extensions.ARB_shading_language_100 = GL_TRUE; 2417117f1b4Smrg#endif 2427117f1b4Smrg#if FEATURE_ARB_shading_language_120 2437117f1b4Smrg ctx->Extensions.ARB_shading_language_120 = GL_TRUE; 2447117f1b4Smrg#endif 2457117f1b4Smrg ctx->Extensions.ARB_shadow = GL_TRUE; 2464a49301eSmrg ctx->Extensions.ARB_shadow_ambient = GL_TRUE; 2477117f1b4Smrg ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; 2487117f1b4Smrg ctx->Extensions.ARB_texture_cube_map = GL_TRUE; 2497117f1b4Smrg ctx->Extensions.ARB_texture_env_combine = GL_TRUE; 2507117f1b4Smrg ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; 2517117f1b4Smrg ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; 2527117f1b4Smrg /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/ 2537117f1b4Smrg ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; 2547117f1b4Smrg ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; 2554a49301eSmrg ctx->Extensions.ARB_vertex_array_object = GL_TRUE; 2567117f1b4Smrg#if FEATURE_ARB_vertex_program 2577117f1b4Smrg ctx->Extensions.ARB_vertex_program = GL_TRUE; 2587117f1b4Smrg#endif 2597117f1b4Smrg#if FEATURE_ARB_vertex_shader 2607117f1b4Smrg ctx->Extensions.ARB_vertex_shader = GL_TRUE; 2617117f1b4Smrg#endif 2627117f1b4Smrg#if FEATURE_ARB_vertex_buffer_object 2634a49301eSmrg /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ 2644a49301eSmrg#endif 2654a49301eSmrg#if FEATURE_ARB_sync 2664a49301eSmrg ctx->Extensions.ARB_sync = GL_TRUE; 2677117f1b4Smrg#endif 2687117f1b4Smrg ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; 269cdc920a0Smrg#if FEATURE_APPLE_object_purgeable 270cdc920a0Smrg ctx->Extensions.APPLE_object_purgeable = GL_TRUE; 271cdc920a0Smrg#endif 2724a49301eSmrg ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE; 2737117f1b4Smrg#if FEATURE_ATI_fragment_shader 2747117f1b4Smrg ctx->Extensions.ATI_fragment_shader = GL_TRUE; 2757117f1b4Smrg#endif 2767117f1b4Smrg ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; 2777117f1b4Smrg ctx->Extensions.ATI_texture_mirror_once = GL_TRUE; 2787117f1b4Smrg ctx->Extensions.ATI_separate_stencil = GL_TRUE; 2797117f1b4Smrg ctx->Extensions.EXT_blend_color = GL_TRUE; 2807117f1b4Smrg ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; 2817117f1b4Smrg ctx->Extensions.EXT_blend_func_separate = GL_TRUE; 2827117f1b4Smrg ctx->Extensions.EXT_blend_logic_op = GL_TRUE; 2837117f1b4Smrg ctx->Extensions.EXT_blend_minmax = GL_TRUE; 2847117f1b4Smrg ctx->Extensions.EXT_blend_subtract = GL_TRUE; 2857117f1b4Smrg ctx->Extensions.EXT_convolution = GL_TRUE; 2867117f1b4Smrg ctx->Extensions.EXT_depth_bounds_test = GL_TRUE; 287cdc920a0Smrg ctx->Extensions.EXT_draw_buffers2 = GL_TRUE; 2887117f1b4Smrg ctx->Extensions.EXT_fog_coord = GL_TRUE; 2897117f1b4Smrg#if FEATURE_EXT_framebuffer_object 2907117f1b4Smrg ctx->Extensions.EXT_framebuffer_object = GL_TRUE; 2917117f1b4Smrg#endif 2927117f1b4Smrg#if FEATURE_EXT_framebuffer_blit 2937117f1b4Smrg ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; 2944a49301eSmrg#endif 2954a49301eSmrg#if FEATURE_ARB_framebuffer_object 2964a49301eSmrg ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; 2977117f1b4Smrg#endif 2987117f1b4Smrg ctx->Extensions.EXT_histogram = GL_TRUE; 2994a49301eSmrg /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ 3007117f1b4Smrg ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; 3017117f1b4Smrg ctx->Extensions.EXT_paletted_texture = GL_TRUE; 3027117f1b4Smrg#if FEATURE_EXT_pixel_buffer_object 3037117f1b4Smrg ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; 3047117f1b4Smrg#endif 3057117f1b4Smrg ctx->Extensions.EXT_point_parameters = GL_TRUE; 3064a49301eSmrg ctx->Extensions.EXT_provoking_vertex = GL_TRUE; 3077117f1b4Smrg ctx->Extensions.EXT_shadow_funcs = GL_TRUE; 3087117f1b4Smrg ctx->Extensions.EXT_secondary_color = GL_TRUE; 3097117f1b4Smrg ctx->Extensions.EXT_shared_texture_palette = GL_TRUE; 3107117f1b4Smrg ctx->Extensions.EXT_stencil_wrap = GL_TRUE; 311c1f859d4Smrg ctx->Extensions.EXT_stencil_two_side = GL_TRUE; 312cdc920a0Smrg ctx->Extensions.EXT_texture_array = GL_TRUE; 3137117f1b4Smrg ctx->Extensions.EXT_texture_env_add = GL_TRUE; 3147117f1b4Smrg ctx->Extensions.EXT_texture_env_combine = GL_TRUE; 3157117f1b4Smrg ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; 3167117f1b4Smrg ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE; 3177117f1b4Smrg ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; 3187117f1b4Smrg#if FEATURE_EXT_texture_sRGB 3197117f1b4Smrg ctx->Extensions.EXT_texture_sRGB = GL_TRUE; 3207117f1b4Smrg#endif 3214a49301eSmrg ctx->Extensions.EXT_texture_swizzle = GL_TRUE; 3224a49301eSmrg ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; 3234a49301eSmrg /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/ 3247117f1b4Smrg ctx->Extensions.MESA_pack_invert = GL_TRUE; 3257117f1b4Smrg ctx->Extensions.MESA_resize_buffers = GL_TRUE; 326c1f859d4Smrg ctx->Extensions.MESA_texture_array = GL_TRUE; 3277117f1b4Smrg ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; 3287117f1b4Smrg ctx->Extensions.NV_blend_square = GL_TRUE; 329cdc920a0Smrg ctx->Extensions.NV_conditional_render = GL_TRUE; 3307117f1b4Smrg /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/ 3317117f1b4Smrg ctx->Extensions.NV_point_sprite = GL_TRUE; 3324a49301eSmrg ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; 3337117f1b4Smrg ctx->Extensions.NV_texture_rectangle = GL_TRUE; 3347117f1b4Smrg /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/ 3357117f1b4Smrg#if FEATURE_NV_vertex_program 3367117f1b4Smrg ctx->Extensions.NV_vertex_program = GL_TRUE; 3377117f1b4Smrg ctx->Extensions.NV_vertex_program1_1 = GL_TRUE; 3387117f1b4Smrg#endif 3397117f1b4Smrg#if FEATURE_NV_fragment_program 3407117f1b4Smrg ctx->Extensions.NV_fragment_program = GL_TRUE; 3414a49301eSmrg#endif 3424a49301eSmrg#if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program 3434a49301eSmrg ctx->Extensions.NV_fragment_program_option = GL_TRUE; 3447117f1b4Smrg#endif 3457117f1b4Smrg ctx->Extensions.SGI_color_matrix = GL_TRUE; 3467117f1b4Smrg ctx->Extensions.SGI_color_table = GL_TRUE; 3477117f1b4Smrg ctx->Extensions.SGI_texture_color_table = GL_TRUE; 3487117f1b4Smrg ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; 3497117f1b4Smrg ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE; 3507117f1b4Smrg#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program 3517117f1b4Smrg ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; 3527117f1b4Smrg#endif 353c1f859d4Smrg#if FEATURE_texture_fxt1 354c1f859d4Smrg _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1"); 355c1f859d4Smrg#endif 356c1f859d4Smrg#if FEATURE_texture_s3tc 357c1f859d4Smrg if (ctx->Mesa_DXTn) { 358c1f859d4Smrg _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); 359c1f859d4Smrg _mesa_enable_extension(ctx, "GL_S3_s3tc"); 360c1f859d4Smrg } 361c1f859d4Smrg#endif 3627117f1b4Smrg} 3637117f1b4Smrg 3647117f1b4Smrg 3657117f1b4Smrg/** 3667117f1b4Smrg * Enable GL_ARB_imaging and all the EXT extensions that are subsets of it. 3677117f1b4Smrg */ 3687117f1b4Smrgvoid 3697117f1b4Smrg_mesa_enable_imaging_extensions(GLcontext *ctx) 3707117f1b4Smrg{ 3717117f1b4Smrg ctx->Extensions.ARB_imaging = GL_TRUE; 3727117f1b4Smrg ctx->Extensions.EXT_blend_color = GL_TRUE; 373c1f859d4Smrg ctx->Extensions.EXT_blend_logic_op = GL_TRUE; 3747117f1b4Smrg ctx->Extensions.EXT_blend_minmax = GL_TRUE; 3757117f1b4Smrg ctx->Extensions.EXT_blend_subtract = GL_TRUE; 3767117f1b4Smrg ctx->Extensions.EXT_convolution = GL_TRUE; 3777117f1b4Smrg ctx->Extensions.EXT_histogram = GL_TRUE; 3787117f1b4Smrg ctx->Extensions.SGI_color_matrix = GL_TRUE; 3797117f1b4Smrg ctx->Extensions.SGI_color_table = GL_TRUE; 3807117f1b4Smrg} 3817117f1b4Smrg 3827117f1b4Smrg 3837117f1b4Smrg 3847117f1b4Smrg/** 3857117f1b4Smrg * Enable all OpenGL 1.3 features and extensions. 3867117f1b4Smrg * A convenience function to be called by drivers. 3877117f1b4Smrg */ 3887117f1b4Smrgvoid 3897117f1b4Smrg_mesa_enable_1_3_extensions(GLcontext *ctx) 3907117f1b4Smrg{ 3914a49301eSmrg /*ctx->Extensions.ARB_multisample = GL_TRUE;*/ 3927117f1b4Smrg ctx->Extensions.ARB_multitexture = GL_TRUE; 3937117f1b4Smrg ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; 3944a49301eSmrg /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/ 3957117f1b4Smrg ctx->Extensions.ARB_texture_cube_map = GL_TRUE; 3967117f1b4Smrg ctx->Extensions.ARB_texture_env_combine = GL_TRUE; 3977117f1b4Smrg ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; 3987117f1b4Smrg ctx->Extensions.EXT_texture_env_add = GL_TRUE; 3997117f1b4Smrg /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/ 4007117f1b4Smrg} 4017117f1b4Smrg 4027117f1b4Smrg 4037117f1b4Smrg 4047117f1b4Smrg/** 4057117f1b4Smrg * Enable all OpenGL 1.4 features and extensions. 4067117f1b4Smrg * A convenience function to be called by drivers. 4077117f1b4Smrg */ 4087117f1b4Smrgvoid 4097117f1b4Smrg_mesa_enable_1_4_extensions(GLcontext *ctx) 4107117f1b4Smrg{ 4117117f1b4Smrg ctx->Extensions.ARB_depth_texture = GL_TRUE; 4127117f1b4Smrg ctx->Extensions.ARB_shadow = GL_TRUE; 4137117f1b4Smrg ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; 4147117f1b4Smrg ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; 4157117f1b4Smrg ctx->Extensions.ARB_window_pos = GL_TRUE; 4167117f1b4Smrg ctx->Extensions.EXT_blend_color = GL_TRUE; 4177117f1b4Smrg ctx->Extensions.EXT_blend_func_separate = GL_TRUE; 4187117f1b4Smrg ctx->Extensions.EXT_blend_minmax = GL_TRUE; 4197117f1b4Smrg ctx->Extensions.EXT_blend_subtract = GL_TRUE; 4207117f1b4Smrg ctx->Extensions.EXT_fog_coord = GL_TRUE; 4214a49301eSmrg /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ 4227117f1b4Smrg ctx->Extensions.EXT_point_parameters = GL_TRUE; 4237117f1b4Smrg ctx->Extensions.EXT_secondary_color = GL_TRUE; 4247117f1b4Smrg ctx->Extensions.EXT_stencil_wrap = GL_TRUE; 4257117f1b4Smrg ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; 4267117f1b4Smrg ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; 4277117f1b4Smrg} 4287117f1b4Smrg 4297117f1b4Smrg 4307117f1b4Smrg/** 4317117f1b4Smrg * Enable all OpenGL 1.5 features and extensions. 4327117f1b4Smrg * A convenience function to be called by drivers. 4337117f1b4Smrg */ 4347117f1b4Smrgvoid 4357117f1b4Smrg_mesa_enable_1_5_extensions(GLcontext *ctx) 4367117f1b4Smrg{ 4377117f1b4Smrg ctx->Extensions.ARB_occlusion_query = GL_TRUE; 4384a49301eSmrg /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ 4397117f1b4Smrg ctx->Extensions.EXT_shadow_funcs = GL_TRUE; 4407117f1b4Smrg} 4417117f1b4Smrg 4427117f1b4Smrg 4437117f1b4Smrg/** 4447117f1b4Smrg * Enable all OpenGL 2.0 features and extensions. 4457117f1b4Smrg * A convenience function to be called by drivers. 4467117f1b4Smrg */ 4477117f1b4Smrgvoid 4487117f1b4Smrg_mesa_enable_2_0_extensions(GLcontext *ctx) 4497117f1b4Smrg{ 4504a49301eSmrg /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ 4517117f1b4Smrg#if FEATURE_ARB_fragment_shader 4527117f1b4Smrg ctx->Extensions.ARB_fragment_shader = GL_TRUE; 4537117f1b4Smrg#endif 4547117f1b4Smrg ctx->Extensions.ARB_point_sprite = GL_TRUE; 4554a49301eSmrg ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; 4567117f1b4Smrg ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; 4577117f1b4Smrg#if FEATURE_ARB_shader_objects 4587117f1b4Smrg ctx->Extensions.ARB_shader_objects = GL_TRUE; 4597117f1b4Smrg#endif 4607117f1b4Smrg#if FEATURE_ARB_shading_language_100 4617117f1b4Smrg ctx->Extensions.ARB_shading_language_100 = GL_TRUE; 4627117f1b4Smrg#endif 463c1f859d4Smrg ctx->Extensions.EXT_stencil_two_side = GL_TRUE; 4647117f1b4Smrg#if FEATURE_ARB_vertex_shader 4657117f1b4Smrg ctx->Extensions.ARB_vertex_shader = GL_TRUE; 4667117f1b4Smrg#endif 4677117f1b4Smrg} 4687117f1b4Smrg 4697117f1b4Smrg 4707117f1b4Smrg/** 4717117f1b4Smrg * Enable all OpenGL 2.1 features and extensions. 4727117f1b4Smrg * A convenience function to be called by drivers. 4737117f1b4Smrg */ 4747117f1b4Smrgvoid 4757117f1b4Smrg_mesa_enable_2_1_extensions(GLcontext *ctx) 4767117f1b4Smrg{ 4777117f1b4Smrg#if FEATURE_EXT_pixel_buffer_object 4787117f1b4Smrg ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; 4797117f1b4Smrg#endif 4807117f1b4Smrg#if FEATURE_EXT_texture_sRGB 4817117f1b4Smrg ctx->Extensions.EXT_texture_sRGB = GL_TRUE; 4827117f1b4Smrg#endif 4837117f1b4Smrg#ifdef FEATURE_ARB_shading_language_120 4847117f1b4Smrg ctx->Extensions.ARB_shading_language_120 = GL_TRUE; 4857117f1b4Smrg#endif 4867117f1b4Smrg} 4877117f1b4Smrg 4887117f1b4Smrg 4897117f1b4Smrg 4907117f1b4Smrg/** 4917117f1b4Smrg * Either enable or disable the named extension. 4924a49301eSmrg * \return GL_TRUE for success, GL_FALSE if invalid extension name 4937117f1b4Smrg */ 4944a49301eSmrgstatic GLboolean 4957117f1b4Smrgset_extension( GLcontext *ctx, const char *name, GLboolean state ) 4967117f1b4Smrg{ 4977117f1b4Smrg GLboolean *base = (GLboolean *) &ctx->Extensions; 4987117f1b4Smrg GLuint i; 4997117f1b4Smrg 5007117f1b4Smrg if (ctx->Extensions.String) { 5017117f1b4Smrg /* The string was already queried - can't change it now! */ 5027117f1b4Smrg _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name); 5034a49301eSmrg return GL_FALSE; 5047117f1b4Smrg } 5057117f1b4Smrg 5067117f1b4Smrg for (i = 0 ; i < Elements(default_extensions) ; i++) { 507cdc920a0Smrg if (strcmp(default_extensions[i].name, name) == 0) { 5087117f1b4Smrg if (default_extensions[i].flag_offset) { 5097117f1b4Smrg GLboolean *enabled = base + default_extensions[i].flag_offset; 5107117f1b4Smrg *enabled = state; 5117117f1b4Smrg } 5124a49301eSmrg return GL_TRUE; 5137117f1b4Smrg } 5147117f1b4Smrg } 5154a49301eSmrg return GL_FALSE; 5167117f1b4Smrg} 5177117f1b4Smrg 5187117f1b4Smrg 5197117f1b4Smrg/** 5207117f1b4Smrg * Enable the named extension. 5217117f1b4Smrg * Typically called by drivers. 5227117f1b4Smrg */ 5237117f1b4Smrgvoid 5247117f1b4Smrg_mesa_enable_extension( GLcontext *ctx, const char *name ) 5257117f1b4Smrg{ 5264a49301eSmrg if (!set_extension(ctx, name, GL_TRUE)) 5274a49301eSmrg _mesa_problem(ctx, "Trying to enable unknown extension: %s", name); 5287117f1b4Smrg} 5297117f1b4Smrg 5307117f1b4Smrg 5317117f1b4Smrg/** 5327117f1b4Smrg * Disable the named extension. 5337117f1b4Smrg * XXX is this really needed??? 5347117f1b4Smrg */ 5357117f1b4Smrgvoid 5367117f1b4Smrg_mesa_disable_extension( GLcontext *ctx, const char *name ) 5377117f1b4Smrg{ 5384a49301eSmrg if (!set_extension(ctx, name, GL_FALSE)) 5394a49301eSmrg _mesa_problem(ctx, "Trying to disable unknown extension: %s", name); 5407117f1b4Smrg} 5417117f1b4Smrg 5427117f1b4Smrg 543cdc920a0Smrg/** 544cdc920a0Smrg * Check if the i-th extension is enabled. 545cdc920a0Smrg */ 546cdc920a0Smrgstatic GLboolean 547cdc920a0Smrgextension_enabled(GLcontext *ctx, GLuint index) 548cdc920a0Smrg{ 549cdc920a0Smrg const GLboolean *base = (const GLboolean *) &ctx->Extensions; 550cdc920a0Smrg if (!default_extensions[index].flag_offset || 551cdc920a0Smrg *(base + default_extensions[index].flag_offset)) { 552cdc920a0Smrg return GL_TRUE; 553cdc920a0Smrg } 554cdc920a0Smrg else { 555cdc920a0Smrg return GL_FALSE; 556cdc920a0Smrg } 557cdc920a0Smrg} 558cdc920a0Smrg 559cdc920a0Smrg 5607117f1b4Smrg/** 5617117f1b4Smrg * Test if the named extension is enabled in this context. 5627117f1b4Smrg */ 5637117f1b4SmrgGLboolean 5647117f1b4Smrg_mesa_extension_is_enabled( GLcontext *ctx, const char *name ) 5657117f1b4Smrg{ 5667117f1b4Smrg GLuint i; 5677117f1b4Smrg 5687117f1b4Smrg for (i = 0 ; i < Elements(default_extensions) ; i++) { 569cdc920a0Smrg if (strcmp(default_extensions[i].name, name) == 0) { 570cdc920a0Smrg return extension_enabled(ctx, i); 5717117f1b4Smrg } 5727117f1b4Smrg } 5737117f1b4Smrg return GL_FALSE; 5747117f1b4Smrg} 5757117f1b4Smrg 5767117f1b4Smrg 5774a49301eSmrg/** 5784a49301eSmrg * Append string 'b' onto string 'a'. Free 'a' and return new string. 5794a49301eSmrg */ 5804a49301eSmrgstatic char * 5814a49301eSmrgappend(const char *a, const char *b) 5824a49301eSmrg{ 583cdc920a0Smrg const GLuint aLen = a ? strlen(a) : 0; 584cdc920a0Smrg const GLuint bLen = b ? strlen(b) : 0; 585cdc920a0Smrg char *s = calloc(1, aLen + bLen + 1); 5864a49301eSmrg if (s) { 5874a49301eSmrg if (a) 588cdc920a0Smrg memcpy(s, a, aLen); 5894a49301eSmrg if (b) 590cdc920a0Smrg memcpy(s + aLen, b, bLen); 5914a49301eSmrg s[aLen + bLen] = '\0'; 5924a49301eSmrg } 5934a49301eSmrg if (a) 594cdc920a0Smrg free((void *) a); 5954a49301eSmrg return s; 5964a49301eSmrg} 5974a49301eSmrg 5984a49301eSmrg 5994a49301eSmrg/** 6004a49301eSmrg * Check the MESA_EXTENSION_OVERRIDE env var. 6014a49301eSmrg * For extension names that are recognized, turn them on. For extension 6024a49301eSmrg * names that are recognized and prefixed with '-', turn them off. 6034a49301eSmrg * Return a string of the unknown/leftover names. 6044a49301eSmrg */ 6054a49301eSmrgstatic const char * 6064a49301eSmrgget_extension_override( GLcontext *ctx ) 6074a49301eSmrg{ 6084a49301eSmrg const char *envExt = _mesa_getenv("MESA_EXTENSION_OVERRIDE"); 6094a49301eSmrg char *extraExt = NULL; 6104a49301eSmrg char ext[1000]; 6114a49301eSmrg GLuint extLen = 0; 6124a49301eSmrg GLuint i; 6134a49301eSmrg GLboolean disableExt = GL_FALSE; 6144a49301eSmrg 6154a49301eSmrg if (!envExt) 6164a49301eSmrg return NULL; 6174a49301eSmrg 6184a49301eSmrg for (i = 0; ; i++) { 6194a49301eSmrg if (envExt[i] == '\0' || envExt[i] == ' ') { 6204a49301eSmrg /* terminate/process 'ext' if extLen > 0 */ 6214a49301eSmrg if (extLen > 0) { 6224a49301eSmrg assert(extLen < sizeof(ext)); 6234a49301eSmrg /* enable extension named by 'ext' */ 6244a49301eSmrg ext[extLen] = 0; 6254a49301eSmrg if (!set_extension(ctx, ext, !disableExt)) { 6264a49301eSmrg /* unknown extension name, append it to extraExt */ 6274a49301eSmrg if (extraExt) { 6284a49301eSmrg extraExt = append(extraExt, " "); 6294a49301eSmrg } 6304a49301eSmrg extraExt = append(extraExt, ext); 6314a49301eSmrg } 6324a49301eSmrg extLen = 0; 6334a49301eSmrg disableExt = GL_FALSE; 6344a49301eSmrg } 6354a49301eSmrg if (envExt[i] == '\0') 6364a49301eSmrg break; 6374a49301eSmrg } 6384a49301eSmrg else if (envExt[i] == '-') { 6394a49301eSmrg disableExt = GL_TRUE; 6404a49301eSmrg } 6414a49301eSmrg else { 6424a49301eSmrg /* accumulate this non-space character */ 6434a49301eSmrg ext[extLen++] = envExt[i]; 6444a49301eSmrg } 6454a49301eSmrg } 6464a49301eSmrg 6474a49301eSmrg return extraExt; 6484a49301eSmrg} 6494a49301eSmrg 6504a49301eSmrg 6517117f1b4Smrg/** 6527117f1b4Smrg * Run through the default_extensions array above and set the 6537117f1b4Smrg * ctx->Extensions.ARB/EXT_* flags accordingly. 6547117f1b4Smrg * To be called during context initialization. 6557117f1b4Smrg */ 6567117f1b4Smrgvoid 6577117f1b4Smrg_mesa_init_extensions( GLcontext *ctx ) 6587117f1b4Smrg{ 6597117f1b4Smrg GLboolean *base = (GLboolean *) &ctx->Extensions; 6607117f1b4Smrg GLuint i; 6617117f1b4Smrg 6627117f1b4Smrg for (i = 0 ; i < Elements(default_extensions) ; i++) { 6637117f1b4Smrg if (default_extensions[i].enabled && 6647117f1b4Smrg default_extensions[i].flag_offset) { 6657117f1b4Smrg *(base + default_extensions[i].flag_offset) = GL_TRUE; 6667117f1b4Smrg } 6677117f1b4Smrg } 6687117f1b4Smrg} 6697117f1b4Smrg 6707117f1b4Smrg 6717117f1b4Smrg/** 6727117f1b4Smrg * Construct the GL_EXTENSIONS string. Called the first time that 6737117f1b4Smrg * glGetString(GL_EXTENSIONS) is called. 6747117f1b4Smrg */ 6757117f1b4SmrgGLubyte * 6767117f1b4Smrg_mesa_make_extension_string( GLcontext *ctx ) 6777117f1b4Smrg{ 6784a49301eSmrg const char *extraExt = get_extension_override(ctx); 6797117f1b4Smrg GLuint extStrLen = 0; 6804a49301eSmrg char *s; 6817117f1b4Smrg GLuint i; 6827117f1b4Smrg 6837117f1b4Smrg /* first, compute length of the extension string */ 6847117f1b4Smrg for (i = 0 ; i < Elements(default_extensions) ; i++) { 685cdc920a0Smrg if (extension_enabled(ctx, i)) { 686cdc920a0Smrg extStrLen += (GLuint) strlen(default_extensions[i].name) + 1; 6877117f1b4Smrg } 6887117f1b4Smrg } 6894a49301eSmrg 6904a49301eSmrg if (extraExt) 691cdc920a0Smrg extStrLen += strlen(extraExt) + 1; /* +1 for space */ 6924a49301eSmrg 6934a49301eSmrg /* allocate the extension string */ 694cdc920a0Smrg s = (char *) malloc(extStrLen); 6954a49301eSmrg if (!s) 6964a49301eSmrg return NULL; 6977117f1b4Smrg 6987117f1b4Smrg /* second, build the extension string */ 6997117f1b4Smrg extStrLen = 0; 7007117f1b4Smrg for (i = 0 ; i < Elements(default_extensions) ; i++) { 701cdc920a0Smrg if (extension_enabled(ctx, i)) { 702cdc920a0Smrg GLuint len = (GLuint) strlen(default_extensions[i].name); 703cdc920a0Smrg memcpy(s + extStrLen, default_extensions[i].name, len); 7047117f1b4Smrg extStrLen += len; 7054a49301eSmrg s[extStrLen] = ' '; 7067117f1b4Smrg extStrLen++; 7077117f1b4Smrg } 7087117f1b4Smrg } 7097117f1b4Smrg ASSERT(extStrLen > 0); 7107117f1b4Smrg 7114a49301eSmrg s[extStrLen - 1] = 0; /* -1 to overwrite trailing the ' ' */ 7127117f1b4Smrg 7134a49301eSmrg if (extraExt) { 7144a49301eSmrg s = append(s, " "); 7154a49301eSmrg s = append(s, extraExt); 7164a49301eSmrg } 7174a49301eSmrg 7184a49301eSmrg return (GLubyte *) s; 7197117f1b4Smrg} 720cdc920a0Smrg 721cdc920a0Smrg 722cdc920a0Smrg/** 723cdc920a0Smrg * Return number of enabled extensions. 724cdc920a0Smrg */ 725cdc920a0SmrgGLuint 726cdc920a0Smrg_mesa_get_extension_count(GLcontext *ctx) 727cdc920a0Smrg{ 728cdc920a0Smrg GLuint i; 729cdc920a0Smrg 730cdc920a0Smrg /* only count once */ 731cdc920a0Smrg if (!ctx->Extensions.Count) { 732cdc920a0Smrg for (i = 0; i < Elements(default_extensions); i++) { 733cdc920a0Smrg if (extension_enabled(ctx, i)) { 734cdc920a0Smrg ctx->Extensions.Count++; 735cdc920a0Smrg } 736cdc920a0Smrg } 737cdc920a0Smrg } 738cdc920a0Smrg 739cdc920a0Smrg if (0) 740cdc920a0Smrg _mesa_debug(ctx, "%u of %d extensions enabled\n", ctx->Extensions.Count, 741cdc920a0Smrg Elements(default_extensions)); 742cdc920a0Smrg 743cdc920a0Smrg return ctx->Extensions.Count; 744cdc920a0Smrg} 745cdc920a0Smrg 746cdc920a0Smrg 747cdc920a0Smrg/** 748cdc920a0Smrg * Return name of i-th enabled extension 749cdc920a0Smrg */ 750cdc920a0Smrgconst GLubyte * 751cdc920a0Smrg_mesa_get_enabled_extension(GLcontext *ctx, GLuint index) 752cdc920a0Smrg{ 753cdc920a0Smrg GLuint i; 754cdc920a0Smrg 755cdc920a0Smrg for (i = 0; i < Elements(default_extensions); i++) { 756cdc920a0Smrg if (extension_enabled(ctx, i)) { 757cdc920a0Smrg if (index == 0) 758cdc920a0Smrg return (const GLubyte *) default_extensions[i].name; 759cdc920a0Smrg index--; 760cdc920a0Smrg } 761cdc920a0Smrg } 762cdc920a0Smrg 763cdc920a0Smrg return NULL; 764cdc920a0Smrg} 765