Charles Davis : winemac.drv: Advertise some legacy WGL extensions in the GL_EXTENSIONS string.

Alexandre Julliard julliard at winehq.org
Fri Aug 16 14:23:46 CDT 2013


Module: wine
Branch: master
Commit: 8a041504c8b1dbfdba5c32d889cfd59ffae23b87
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=8a041504c8b1dbfdba5c32d889cfd59ffae23b87

Author: Charles Davis <cdavis5x at gmail.com>
Date:   Mon Aug 12 15:07:04 2013 -0600

winemac.drv: Advertise some legacy WGL extensions in the GL_EXTENSIONS string.

---

 dlls/winemac.drv/opengl.c |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c
index fb294d1..7327e12 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);
 
@@ -1516,6 +1527,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
  *
  * Hook into glReadPixels as part of the implementation of
@@ -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)




More information about the wine-cvs mailing list