mesa: Compute GL version according to API

This commit is contained in:
Kristian Høgsberg 2010-04-21 16:14:18 -04:00
parent ba34fdb5b9
commit df4d6bcbe8
3 changed files with 107 additions and 80 deletions

View file

@ -32,33 +32,6 @@
extern const GLubyte * GLAPIENTRY _es_GetString(GLenum name);
static const GLubyte *
compute_es_version(void)
{
GET_CURRENT_CONTEXT(ctx);
static const char es_1_0[] = "OpenGL ES-CM 1.0";
static const char es_1_1[] = "OpenGL ES-CM 1.1";
/* OpenGL ES 1.0 is derived from OpenGL 1.3 */
const GLboolean ver_1_0 = (ctx->Extensions.ARB_multisample &&
ctx->Extensions.ARB_multitexture &&
ctx->Extensions.ARB_texture_compression &&
ctx->Extensions.EXT_texture_env_add &&
ctx->Extensions.ARB_texture_env_combine &&
ctx->Extensions.ARB_texture_env_dot3);
/* OpenGL ES 1.1 is derived from OpenGL 1.5 */
const GLboolean ver_1_1 = (ver_1_0 &&
ctx->Extensions.EXT_point_parameters &&
ctx->Extensions.SGIS_generate_mipmap &&
ctx->Extensions.ARB_vertex_buffer_object);
if (ver_1_1)
return (const GLubyte *) es_1_1;
if (!ver_1_0)
_mesa_problem(ctx, "Incomplete OpenGL ES 1.0 support.");
return (const GLubyte *) es_1_0;
}
static size_t
append_extension(char **str, const char *ext)
{
@ -182,8 +155,6 @@ const GLubyte * GLAPIENTRY
_es_GetString(GLenum name)
{
switch (name) {
case GL_VERSION:
return compute_es_version();
case GL_EXTENSIONS:
return compute_es_extensions();
default:

View file

@ -32,34 +32,6 @@
const GLubyte * GLAPIENTRY _es_GetString(GLenum name);
static const GLubyte *
compute_es_version(void)
{
GET_CURRENT_CONTEXT(ctx);
static const char es_2_0[] = "OpenGL ES 2.0";
/* OpenGL ES 2.0 is derived from OpenGL 2.0 */
const GLboolean ver_2_0 = (ctx->Extensions.ARB_multisample &&
ctx->Extensions.ARB_multitexture &&
ctx->Extensions.ARB_texture_compression &&
ctx->Extensions.ARB_texture_cube_map &&
ctx->Extensions.ARB_texture_mirrored_repeat &&
ctx->Extensions.EXT_blend_color &&
ctx->Extensions.EXT_blend_func_separate &&
ctx->Extensions.EXT_blend_minmax &&
ctx->Extensions.EXT_blend_subtract &&
ctx->Extensions.EXT_stencil_wrap &&
ctx->Extensions.ARB_vertex_buffer_object &&
ctx->Extensions.ARB_shader_objects &&
ctx->Extensions.ARB_vertex_shader &&
ctx->Extensions.ARB_fragment_shader &&
ctx->Extensions.ARB_texture_non_power_of_two &&
ctx->Extensions.EXT_blend_equation_separate);
if (!ver_2_0)
_mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support.");
return (const GLubyte *) es_2_0;
}
static size_t
append_extension(char **str, const char *ext)
{
@ -152,8 +124,6 @@ const GLubyte * GLAPIENTRY
_es_GetString(GLenum name)
{
switch (name) {
case GL_VERSION:
return compute_es_version();
case GL_SHADING_LANGUAGE_VERSION:
return (const GLubyte *) "OpenGL ES GLSL ES 1.0.16";
case GL_EXTENSIONS:

View file

@ -32,8 +32,11 @@
* Return major and minor version numbers.
*/
static void
compute_version(const GLcontext *ctx, GLuint *major, GLuint *minor)
compute_version(GLcontext *ctx)
{
GLuint major, minor;
static const int max = 100;
const GLboolean ver_1_3 = (ctx->Extensions.ARB_multisample &&
ctx->Extensions.ARB_multitexture &&
ctx->Extensions.ARB_texture_border_clamp &&
@ -85,31 +88,111 @@ compute_version(const GLcontext *ctx, GLuint *major, GLuint *minor)
ctx->Extensions.EXT_pixel_buffer_object &&
ctx->Extensions.EXT_texture_sRGB);
if (ver_2_1) {
*major = 2;
*minor = 1;
major = 2;
minor = 1;
}
else if (ver_2_0) {
*major = 2;
*minor = 0;
major = 2;
minor = 0;
}
else if (ver_1_5) {
*major = 1;
*minor = 5;
major = 1;
minor = 5;
}
else if (ver_1_4) {
*major = 1;
*minor = 4;
major = 1;
minor = 4;
}
else if (ver_1_3) {
*major = 1;
*minor = 3;
major = 1;
minor = 3;
}
else {
*major = 1;
*minor = 2;
major = 1;
minor = 2;
}
ctx->VersionMajor = major;
ctx->VersionMinor = minor;
ctx->VersionString = (char *) malloc(max);
if (ctx->VersionString) {
_mesa_snprintf(ctx->VersionString, max,
"%u.%u Mesa " MESA_VERSION_STRING,
ctx->VersionMajor, ctx->VersionMinor);
}
}
static void
compute_version_es1(GLcontext *ctx)
{
static const int max = 100;
/* OpenGL ES 1.0 is derived from OpenGL 1.3 */
const GLboolean ver_1_0 = (ctx->Extensions.ARB_multisample &&
ctx->Extensions.ARB_multitexture &&
ctx->Extensions.ARB_texture_compression &&
ctx->Extensions.EXT_texture_env_add &&
ctx->Extensions.ARB_texture_env_combine &&
ctx->Extensions.ARB_texture_env_dot3);
/* OpenGL ES 1.1 is derived from OpenGL 1.5 */
const GLboolean ver_1_1 = (ver_1_0 &&
ctx->Extensions.EXT_point_parameters &&
ctx->Extensions.SGIS_generate_mipmap &&
ctx->Extensions.ARB_vertex_buffer_object);
if (ver_1_1) {
ctx->VersionMajor = 1;
ctx->VersionMinor = 1;
} else if (ver_1_0) {
ctx->VersionMajor = 1;
ctx->VersionMinor = 0;
} else {
_mesa_problem(ctx, "Incomplete OpenGL ES 1.0 support.");
}
ctx->VersionString = (char *) malloc(max);
if (ctx->VersionString) {
_mesa_snprintf(ctx->VersionString, max,
"OpenGL ES-CM 1.%d Mesa " MESA_VERSION_STRING,
ctx->VersionMinor);
}
}
static void
compute_version_es2(GLcontext *ctx)
{
static const int max = 100;
/* OpenGL ES 2.0 is derived from OpenGL 2.0 */
const GLboolean ver_2_0 = (ctx->Extensions.ARB_multisample &&
ctx->Extensions.ARB_multitexture &&
ctx->Extensions.ARB_texture_compression &&
ctx->Extensions.ARB_texture_cube_map &&
ctx->Extensions.ARB_texture_mirrored_repeat &&
ctx->Extensions.EXT_blend_color &&
ctx->Extensions.EXT_blend_func_separate &&
ctx->Extensions.EXT_blend_minmax &&
ctx->Extensions.EXT_blend_subtract &&
ctx->Extensions.EXT_stencil_wrap &&
ctx->Extensions.ARB_vertex_buffer_object &&
ctx->Extensions.ARB_shader_objects &&
ctx->Extensions.ARB_vertex_shader &&
ctx->Extensions.ARB_fragment_shader &&
ctx->Extensions.ARB_texture_non_power_of_two &&
ctx->Extensions.EXT_blend_equation_separate);
if (ver_2_0) {
ctx->VersionMajor = 2;
ctx->VersionMinor = 0;
} else {
_mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support.");
}
ctx->VersionString = (char *) malloc(max);
if (ctx->VersionString) {
_mesa_snprintf(ctx->VersionString, max,
"OpenGL ES 2.0 Mesa " MESA_VERSION_STRING);
}
}
/**
* Set the context's VersionMajor, VersionMinor, VersionString fields.
@ -118,13 +201,16 @@ compute_version(const GLcontext *ctx, GLuint *major, GLuint *minor)
void
_mesa_compute_version(GLcontext *ctx)
{
static const int max = 100;
compute_version(ctx, &ctx->VersionMajor, &ctx->VersionMinor);
ctx->VersionString = (char *) malloc(max);
if (ctx->VersionString) {
_mesa_snprintf(ctx->VersionString, max, "%u.%u Mesa " MESA_VERSION_STRING,
ctx->VersionMajor, ctx->VersionMinor);
switch (ctx->API) {
case API_OPENGL:
compute_version(ctx);
break;
case API_OPENGLES:
compute_version_es1(ctx);
break;
case API_OPENGLES2:
compute_version_es2(ctx);
break;
}
}