From d0eb997f8f04c4cf1c42b6f68a97b6e07c90c804 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 16 Apr 2024 20:25:24 +0200 Subject: [PATCH] opengl/gpu: fix GLSL version detection on GLES --- src/opengl/gpu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/opengl/gpu.c b/src/opengl/gpu.c index bed37126..8312242b 100644 --- a/src/opengl/gpu.c +++ b/src/opengl/gpu.c @@ -119,11 +119,13 @@ pl_gpu pl_gpu_create_gl(pl_log log, pl_opengl pl_gl, const struct pl_opengl_para p->gles_ver = glsl->gles ? ver : 0; // If possible, query the GLSL version from the implementation - const char *glslver = (char *) gl->GetString(GL_SHADING_LANGUAGE_VERSION); - if (glslver) { - PL_INFO(gpu, " GL_SHADING_LANGUAGE_VERSION: %s", glslver); + const char *glslver_p = (char *) gl->GetString(GL_SHADING_LANGUAGE_VERSION); + pl_str glslver = pl_str0(glslver_p); + if (glslver.len) { + PL_INFO(gpu, " GL_SHADING_LANGUAGE_VERSION: %.*s", PL_STR_FMT(glslver)); + pl_str_eatstart0(&glslver, "OpenGL ES GLSL ES "); int major = 0, minor = 0; - if (sscanf(glslver, "%d.%d", &major, &minor) == 2) + if (pl_str_sscanf(glslver, "%d.%d", &major, &minor) == 2) glsl->version = major * 100 + minor; }