From 8a041504c8b1dbfdba5c32d889cfd59ffae23b87 Mon Sep 17 00:00:00 2001 From: Charles Davis Date: Mon, 12 Aug 2013 15:07:04 -0600 Subject: [PATCH] winemac.drv: Advertise some legacy WGL extensions in the GL_EXTENSIONS string. --- dlls/winemac.drv/opengl.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index fb294d173d3..7327e12800e 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -104,6 +104,7 @@ static void (*pglCopyColorTable)(GLenum target, GLenum internalformat, GLint x, static void (*pglCopyPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); static void (*pglFlush)(void); static void (*pglFlushRenderAPPLE)(void); +static const GLubyte *(*pglGetString)(GLenum name); static void (*pglReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); static void (*pglViewport)(GLint x, GLint y, GLsizei width, GLsizei height); @@ -1186,6 +1187,9 @@ static const pixel_format *get_pixel_format(int format, BOOL allow_nondisplayabl static BOOL init_gl_info(void) { + static char legacy_extensions[] = " WGL_EXT_extensions_string"; + static const char legacy_ext_swap_control[] = " WGL_EXT_swap_control"; + CGDirectDisplayID display = CGMainDisplayID(); CGOpenGLDisplayMask displayMask = CGDisplayIDToOpenGLDisplayMask(display); CGLPixelFormatAttribute attribs[] = { @@ -1198,6 +1202,7 @@ static BOOL init_gl_info(void) CGLContextObj context; CGLContextObj old_context = CGLGetCurrentContext(); const char *str; + size_t length; err = CGLChoosePixelFormat(attribs, &pix, &virtualScreens); if (err != kCGLNoError || !pix) @@ -1226,8 +1231,14 @@ static BOOL init_gl_info(void) gl_info.glVersion = HeapAlloc(GetProcessHeap(), 0, strlen(str) + 1); strcpy(gl_info.glVersion, str); str = (const char*)opengl_funcs.gl.p_glGetString(GL_EXTENSIONS); - gl_info.glExtensions = HeapAlloc(GetProcessHeap(), 0, strlen(str) + 1); + length = strlen(str) + sizeof(legacy_extensions); + if (allow_vsync) + length += strlen(legacy_ext_swap_control); + gl_info.glExtensions = HeapAlloc(GetProcessHeap(), 0, length); strcpy(gl_info.glExtensions, str); + strcat(gl_info.glExtensions, legacy_extensions); + if (allow_vsync) + strcat(gl_info.glExtensions, legacy_ext_swap_control); opengl_funcs.gl.p_glGetIntegerv(GL_MAX_VIEWPORT_DIMS, gl_info.max_viewport_dims); @@ -1515,6 +1526,26 @@ static void macdrv_glFlush(void) } +/********************************************************************** + * macdrv_glGetString + * + * Hook into glGetString in order to return some legacy WGL extensions + * that couldn't be advertised via the standard + * WGL_ARB_extensions_string mechanism. Some programs, especially + * older ones, expect to find certain older extensions, such as + * WGL_EXT_extensions_string itself, in the standard GL extensions + * string, and won't query any other WGL extensions unless they find + * that particular extension there. + */ +static const GLubyte *macdrv_glGetString(GLenum name) +{ + if (name == GL_EXTENSIONS && gl_info.glExtensions) + return (const GLubyte *)gl_info.glExtensions; + else + return pglGetString(name); +} + + /********************************************************************** * macdrv_glReadPixels * @@ -3054,6 +3085,7 @@ static BOOL init_opengl(void) #define REDIRECT(func) \ do { p##func = opengl_funcs.gl.p_##func; opengl_funcs.gl.p_##func = macdrv_##func; } while(0) REDIRECT(glCopyPixels); + REDIRECT(glGetString); REDIRECT(glReadPixels); REDIRECT(glViewport); if (skip_single_buffer_flushes)