2 * Mesa 3-D graphics library
4 * Copyright (C) 2010 VMware, Inc. All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 * Examine enabled GL extensions to determine GL version.
32 * Return major and minor version numbers.
35 compute_version(GLcontext
*ctx
)
38 static const int max
= 100;
40 const GLboolean ver_1_3
= (ctx
->Extensions
.ARB_multisample
&&
41 ctx
->Extensions
.ARB_multitexture
&&
42 ctx
->Extensions
.ARB_texture_border_clamp
&&
43 ctx
->Extensions
.ARB_texture_compression
&&
44 ctx
->Extensions
.ARB_texture_cube_map
&&
45 ctx
->Extensions
.EXT_texture_env_add
&&
46 ctx
->Extensions
.ARB_texture_env_combine
&&
47 ctx
->Extensions
.ARB_texture_env_dot3
);
48 const GLboolean ver_1_4
= (ver_1_3
&&
49 ctx
->Extensions
.ARB_depth_texture
&&
50 ctx
->Extensions
.ARB_shadow
&&
51 ctx
->Extensions
.ARB_texture_env_crossbar
&&
52 ctx
->Extensions
.ARB_texture_mirrored_repeat
&&
53 ctx
->Extensions
.ARB_window_pos
&&
54 ctx
->Extensions
.EXT_blend_color
&&
55 ctx
->Extensions
.EXT_blend_func_separate
&&
56 ctx
->Extensions
.EXT_blend_minmax
&&
57 ctx
->Extensions
.EXT_blend_subtract
&&
58 ctx
->Extensions
.EXT_fog_coord
&&
59 ctx
->Extensions
.EXT_multi_draw_arrays
&&
60 ctx
->Extensions
.EXT_point_parameters
&&
61 ctx
->Extensions
.EXT_secondary_color
&&
62 ctx
->Extensions
.EXT_stencil_wrap
&&
63 ctx
->Extensions
.EXT_texture_lod_bias
&&
64 ctx
->Extensions
.SGIS_generate_mipmap
);
65 const GLboolean ver_1_5
= (ver_1_4
&&
66 ctx
->Extensions
.ARB_occlusion_query
&&
67 ctx
->Extensions
.ARB_vertex_buffer_object
&&
68 ctx
->Extensions
.EXT_shadow_funcs
);
69 const GLboolean ver_2_0
= (ver_1_5
&&
70 ctx
->Extensions
.ARB_draw_buffers
&&
71 ctx
->Extensions
.ARB_point_sprite
&&
72 ctx
->Extensions
.ARB_shader_objects
&&
73 ctx
->Extensions
.ARB_vertex_shader
&&
74 ctx
->Extensions
.ARB_fragment_shader
&&
75 ctx
->Extensions
.ARB_texture_non_power_of_two
&&
76 ctx
->Extensions
.EXT_blend_equation_separate
&&
78 /* Technically, 2.0 requires the functionality
79 * of the EXT version. Enable 2.0 if either
80 * extension is available, and assume that a
81 * driver that only exposes the ATI extension
82 * will fallback to software when necessary.
84 (ctx
->Extensions
.EXT_stencil_two_side
85 || ctx
->Extensions
.ATI_separate_stencil
));
86 const GLboolean ver_2_1
= (ver_2_0
&&
87 ctx
->Extensions
.ARB_shading_language_120
&&
88 ctx
->Extensions
.EXT_pixel_buffer_object
&&
89 ctx
->Extensions
.EXT_texture_sRGB
);
115 ctx
->VersionMajor
= major
;
116 ctx
->VersionMinor
= minor
;
117 ctx
->VersionString
= (char *) malloc(max
);
118 if (ctx
->VersionString
) {
119 _mesa_snprintf(ctx
->VersionString
, max
,
120 "%u.%u Mesa " MESA_VERSION_STRING
,
121 ctx
->VersionMajor
, ctx
->VersionMinor
);
126 compute_version_es1(GLcontext
*ctx
)
128 static const int max
= 100;
130 /* OpenGL ES 1.0 is derived from OpenGL 1.3 */
131 const GLboolean ver_1_0
= (ctx
->Extensions
.ARB_multisample
&&
132 ctx
->Extensions
.ARB_multitexture
&&
133 ctx
->Extensions
.ARB_texture_compression
&&
134 ctx
->Extensions
.EXT_texture_env_add
&&
135 ctx
->Extensions
.ARB_texture_env_combine
&&
136 ctx
->Extensions
.ARB_texture_env_dot3
);
137 /* OpenGL ES 1.1 is derived from OpenGL 1.5 */
138 const GLboolean ver_1_1
= (ver_1_0
&&
139 ctx
->Extensions
.EXT_point_parameters
&&
140 ctx
->Extensions
.SGIS_generate_mipmap
&&
141 ctx
->Extensions
.ARB_vertex_buffer_object
);
144 ctx
->VersionMajor
= 1;
145 ctx
->VersionMinor
= 1;
146 } else if (ver_1_0
) {
147 ctx
->VersionMajor
= 1;
148 ctx
->VersionMinor
= 0;
150 _mesa_problem(ctx
, "Incomplete OpenGL ES 1.0 support.");
153 ctx
->VersionString
= (char *) malloc(max
);
154 if (ctx
->VersionString
) {
155 _mesa_snprintf(ctx
->VersionString
, max
,
156 "OpenGL ES-CM 1.%d Mesa " MESA_VERSION_STRING
,
162 compute_version_es2(GLcontext
*ctx
)
164 static const int max
= 100;
166 /* OpenGL ES 2.0 is derived from OpenGL 2.0 */
167 const GLboolean ver_2_0
= (ctx
->Extensions
.ARB_multisample
&&
168 ctx
->Extensions
.ARB_multitexture
&&
169 ctx
->Extensions
.ARB_texture_compression
&&
170 ctx
->Extensions
.ARB_texture_cube_map
&&
171 ctx
->Extensions
.ARB_texture_mirrored_repeat
&&
172 ctx
->Extensions
.EXT_blend_color
&&
173 ctx
->Extensions
.EXT_blend_func_separate
&&
174 ctx
->Extensions
.EXT_blend_minmax
&&
175 ctx
->Extensions
.EXT_blend_subtract
&&
176 ctx
->Extensions
.EXT_stencil_wrap
&&
177 ctx
->Extensions
.ARB_vertex_buffer_object
&&
178 ctx
->Extensions
.ARB_shader_objects
&&
179 ctx
->Extensions
.ARB_vertex_shader
&&
180 ctx
->Extensions
.ARB_fragment_shader
&&
181 ctx
->Extensions
.ARB_texture_non_power_of_two
&&
182 ctx
->Extensions
.EXT_blend_equation_separate
);
184 ctx
->VersionMajor
= 2;
185 ctx
->VersionMinor
= 0;
187 _mesa_problem(ctx
, "Incomplete OpenGL ES 2.0 support.");
190 ctx
->VersionString
= (char *) malloc(max
);
191 if (ctx
->VersionString
) {
192 _mesa_snprintf(ctx
->VersionString
, max
,
193 "OpenGL ES 2.0 Mesa " MESA_VERSION_STRING
);
198 * Set the context's VersionMajor, VersionMinor, VersionString fields.
199 * This should only be called once as part of context initialization.
202 _mesa_compute_version(GLcontext
*ctx
)
206 compute_version(ctx
);
209 compute_version_es1(ctx
);
212 compute_version_es2(ctx
);