Module: wine Branch: master Commit: cf1f02e2898fcb6eeb48409641100e49d1d68504 URL: https://gitlab.winehq.org/wine/wine/-/commit/cf1f02e2898fcb6eeb48409641100e4...
Author: Rémi Bernon rbernon@codeweavers.com Date: Fri Oct 7 10:34:02 2022 +0200
opengl32: Split is_extension_supported helper.
---
dlls/opengl32/wgl.c | 53 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-)
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 49f1e4700b4..03117847b9a 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -803,57 +803,45 @@ static int compar(const void *elt_a, const void *elt_b) { }
/* Check if a GL extension is supported */ -static BOOL is_extension_supported(const char* extension) +static BOOL check_extension_support( const char *extension, const char *available_extensions ) { - enum wgl_handle_type type = get_current_context_type(); const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - const char *gl_ext_string = NULL; size_t len;
TRACE("Checking for extension '%s'\n", extension);
- if (type == HANDLE_CONTEXT) - { - gl_ext_string = (const char*)glGetString(GL_EXTENSIONS); - if (!gl_ext_string) - { - ERR("No OpenGL extensions found, check if your OpenGL setup is correct!\n"); - return FALSE; - } - } - /* We use the GetProcAddress function from the display driver to retrieve function pointers * for OpenGL and WGL extensions. In case of winex11.drv the OpenGL extension lookup is done * using glXGetProcAddress. This function is quite unreliable in the sense that its specs don't * require the function to return NULL when an extension isn't found. For this reason we check * if the OpenGL extension required for the function we are looking up is supported. */
- while ((len = strcspn(extension, " ")) != 0) + while ((len = strcspn( extension, " " ))) { /* Check if the extension is part of the GL extension string to see if it is supported. */ - if (has_extension(gl_ext_string, extension, len)) - return TRUE; + if (has_extension( available_extensions, extension, len )) return TRUE;
/* In general an OpenGL function starts as an ARB/EXT extension and at some stage * it becomes part of the core OpenGL library and can be reached without the ARB/EXT * suffix as well. In the extension table, these functions contain GL_VERSION_major_minor. * Check if we are searching for a core GL function */ - if(strncmp(extension, "GL_VERSION_", 11) == 0) + if (!strncmp( extension, "GL_VERSION_", 11 )) { const GLubyte *gl_version = funcs->gl.p_glGetString(GL_VERSION); const char *version = extension + 11; /* Move past 'GL_VERSION_' */
- if(!gl_version) { - ERR("No OpenGL version found!\n"); + if (!gl_version) + { + ERR( "No OpenGL version found!\n" ); return FALSE; }
/* Compare the major/minor version numbers of the native OpenGL library and what is required by the function. * The gl_version string is guaranteed to have at least a major/minor and sometimes it has a release number as well. */ - if( (gl_version[0] > version[0]) || ((gl_version[0] == version[0]) && (gl_version[2] >= version[2])) ) { - return TRUE; - } - WARN("The function requires OpenGL version '%c.%c' while your drivers only provide '%c.%c'\n", version[0], version[2], gl_version[0], gl_version[2]); + if ((gl_version[0] > version[0]) || ((gl_version[0] == version[0]) && (gl_version[2] >= version[2]))) return TRUE; + + WARN( "The function requires OpenGL version '%c.%c' while your drivers only provide '%c.%c'\n", + version[0], version[2], gl_version[0], gl_version[2] ); }
if (extension[len] == ' ') len++; @@ -863,6 +851,25 @@ static BOOL is_extension_supported(const char* extension) return FALSE; }
+/* Check if a GL extension is supported */ +static BOOL is_extension_supported( const char *extension ) +{ + enum wgl_handle_type type = get_current_context_type(); + const char *gl_ext_string = NULL; + + if (type == HANDLE_CONTEXT) + { + gl_ext_string = (const char *)glGetString( GL_EXTENSIONS ); + if (!gl_ext_string) + { + ERR( "No OpenGL extensions found, check if your OpenGL setup is correct!\n" ); + return FALSE; + } + } + + return check_extension_support( extension, gl_ext_string ); +} + /*********************************************************************** * wglGetProcAddress (OPENGL32.@) */