Evas GL: Also return fake GLSL version string

This commit is contained in:
Jean-Philippe Andre 2014-11-27 19:05:26 +09:00
parent 9f38aadd38
commit d8a4792612
1 changed files with 35 additions and 24 deletions

View File

@ -547,10 +547,10 @@ _evgl_glGetIntegerv(GLenum pname, GLint* params)
static const GLubyte * static const GLubyte *
_evgl_glGetString(GLenum name) _evgl_glGetString(GLenum name)
{ {
static char _version[64] = {0}; static char _version[128] = {0};
static char _glsl[128] = {0};
EVGL_Resource *rsc; EVGL_Resource *rsc;
const GLubyte *ret; const GLubyte *ret;
char *r;
/* We wrap two values here: /* We wrap two values here:
* *
@ -583,40 +583,51 @@ _evgl_glGetString(GLenum name)
{ {
case GL_VENDOR: case GL_VENDOR:
case GL_RENDERER: case GL_RENDERER:
case GL_SHADING_LANGUAGE_VERSION: // Keep these as-is.
// GLSL version example strings (for the same GPU):
// For OpenGL ES 2.0 or 3.0: "OpenGL ES GLSL ES 3.10"
// For Desktop OpenGL: "4.40 NVIDIA via Cg compiler"
break; break;
case GL_SHADING_LANGUAGE_VERSION:
ret = glGetString(GL_SHADING_LANGUAGE_VERSION);
if (!ret) return NULL;
#ifdef GL_GLES
if (ret[15] != (GLubyte) '1')
{
// We try not to remove the vendor fluff
snprintf(_glsl, sizeof(_glsl), "OpenGL ES GLSL ES 1.00 Evas GL (%s)", ((char *) ret) + 18);
_glsl[sizeof(_glsl) - 1] = '\0';
return (const GLubyte *) _glsl;
}
return ret;
#else
// Desktop GL, we still keep the official name
snprintf(_glsl, sizeof(_glsl), "OpenGL ES GLSL ES 1.00 Evas GL (%s)", (char *) ret);
_version[sizeof(_glsl) - 1] = '\0';
return (const GLubyte *) _glsl;
#endif
case GL_VERSION: case GL_VERSION:
ret = glGetString(GL_VERSION); ret = glGetString(GL_VERSION);
if (!ret) return NULL; if (!ret) return NULL;
if (strstr((const char *) ret, "OpenGL ES 3")) #ifdef GL_GLES
if (ret[11] != (GLubyte) '2')
{ {
// We try not to remove the vendor fluff (contains driver version) // We try not to remove the vendor fluff
strncpy(_version, (const char *) ret, sizeof(_version)); snprintf(_version, sizeof(_version), "OpenGL ES 2.0 Evas GL (%s)", ((char *) ret) + 10);
r = strchr(_version, '3');
if (r)
{
*r++ = '2';
*r++ = '.';
*r++ = '0';
*r = ' ';
}
_version[sizeof(_version) - 1] = '\0';
return (const GLubyte *) _version;
}
else if (!strstr((const char *) ret, "OpenGL ES"))
{
// Desktop GL, we still keep the official name
snprintf(_version, sizeof(_version), "OpenGL ES 2.0 (%s)", (char *) ret);
_version[sizeof(_version) - 1] = '\0'; _version[sizeof(_version) - 1] = '\0';
return (const GLubyte *) _version; return (const GLubyte *) _version;
} }
return ret; return ret;
#else
// Desktop GL, we still keep the official name
snprintf(_version, sizeof(_version), "OpenGL ES 2.0 Evas GL (%s)", (char *) ret);
_version[sizeof(_version) - 1] = '\0';
return (const GLubyte *) _version;
#endif
case GL_EXTENSIONS: case GL_EXTENSIONS:
return (GLubyte *) evgl_api_ext_string_get return (GLubyte *) evgl_api_ext_string_get
(EINA_TRUE, (rsc->current_ctx->version == EVAS_GL_GLES_1_X)); (EINA_TRUE, (rsc->current_ctx->version == EVAS_GL_GLES_1_X));
default: default:
// GL_INVALID_ENUM is generated if name is not an accepted value. // GL_INVALID_ENUM is generated if name is not an accepted value.
WRN("Unknown string requested: %x", (unsigned int) name); WRN("Unknown string requested: %x", (unsigned int) name);