Roderick Colenbrander : winex11: Store opengl swap interval with gl_drawable.

Alexandre Julliard julliard at winehq.org
Thu May 23 14:42:19 CDT 2013


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

Author: Roderick Colenbrander <thunderbird2k at gmail.com>
Date:   Sat May 11 17:55:18 2013 -0700

winex11: Store opengl swap interval with gl_drawable.

---

 dlls/opengl32/tests/opengl.c |    2 +-
 dlls/winex11.drv/opengl.c    |   42 ++++++++++++++++++++++++++++++++++++------
 2 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c
index 066b026..3aa2c40 100644
--- a/dlls/opengl32/tests/opengl.c
+++ b/dlls/opengl32/tests/opengl.c
@@ -1581,7 +1581,7 @@ static void test_swap_control(HDC oldhdc)
      * is not global or shared among contexts.
      */
     interval = pwglGetSwapIntervalEXT();
-    todo_wine ok(interval == 1, "Expected swap interval 1, got %d\n", interval);
+    ok(interval == 1, "Expected swap interval 1, got %d\n", interval);
 
     ret = wglDeleteContext(ctx1);
     ok(ret, "Failed to delete GL context, last error %#x.\n", GetLastError());
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index c617245..05b8f60 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -251,6 +251,7 @@ struct gl_drawable
     const struct wgl_pixel_format *format;       /* pixel format for the drawable */
     XVisualInfo                   *visual;       /* information about the GL visual */
     RECT                           rect;         /* drawable rect, relative to whole window drawable */
+    int                            swap_interval;
 };
 
 /* X context to associate a struct gl_drawable to an hwnd */
@@ -271,7 +272,6 @@ static struct wgl_pixel_format *pixel_formats;
 static int nb_pixel_formats, nb_onscreen_formats;
 static int use_render_texture_emulation = 1;
 static BOOL has_swap_control;
-static int swap_interval = 1;
 
 static CRITICAL_SECTION context_section;
 static CRITICAL_SECTION_DEBUG critsect_debug =
@@ -1223,6 +1223,10 @@ static void free_gl_drawable( struct gl_drawable *gl )
 static BOOL create_gl_drawable( HWND hwnd, HWND parent, struct gl_drawable *gl )
 {
     gl->drawable = 0;
+    /* Default GLX and WGL swap interval is 1, but in case of glXSwapIntervalSGI
+     * there is no way to query it, so we have to store it here.
+     */
+    gl->swap_interval = 1;
 
     if (GetAncestor( hwnd, GA_PARENT ) == GetDesktopWindow())  /* top-level window */
     {
@@ -2866,9 +2870,24 @@ static const GLubyte *X11DRV_wglGetExtensionsStringEXT(void)
  */
 static int X11DRV_wglGetSwapIntervalEXT(void)
 {
-    /* GLX_SGI_swap_control doesn't have any provisions for getting the swap
-     * interval, so the swap interval has to be tracked. */
+    struct wgl_context *ctx = NtCurrentTeb()->glContext;
+    struct gl_drawable *gl;
+    int swap_interval;
+
     TRACE("()\n");
+
+    if (!(gl = get_gl_drawable( WindowFromDC( ctx->hdc ), ctx->hdc )))
+    {
+        /* This can't happen because a current WGL context is required to get
+         * here. Likely the application is buggy.
+         */
+        WARN("No GL drawable found, returning swap interval 0\n");
+        return 0;
+    }
+
+    swap_interval = gl->swap_interval;
+    release_gl_drawable(gl);
+
     return swap_interval;
 }
 
@@ -2879,6 +2898,8 @@ static int X11DRV_wglGetSwapIntervalEXT(void)
  */
 static BOOL X11DRV_wglSwapIntervalEXT(int interval)
 {
+    struct wgl_context *ctx = NtCurrentTeb()->glContext;
+    struct gl_drawable *gl;
     BOOL ret = TRUE;
 
     TRACE("(%d)\n", interval);
@@ -2888,13 +2909,20 @@ static BOOL X11DRV_wglSwapIntervalEXT(int interval)
         SetLastError(ERROR_INVALID_DATA);
         return FALSE;
     }
-    else if (!has_swap_control && interval == 0)
+
+    if (!(gl = get_gl_drawable( WindowFromDC( ctx->hdc ), ctx->hdc )))
+    {
+        SetLastError(ERROR_DC_NOT_FOUND);
+        return FALSE;
+    }
+
+    if (!has_swap_control && interval == 0)
     {
         /* wglSwapIntervalEXT considers an interval value of zero to mean that
          * vsync should be disabled, but glXSwapIntervalSGI considers such a
          * value to be an error. Just silently ignore the request for now. */
         WARN("Request to disable vertical sync is not handled\n");
-        swap_interval = 0;
+        gl->swap_interval = 0;
     }
     else
     {
@@ -2904,11 +2932,13 @@ static BOOL X11DRV_wglSwapIntervalEXT(int interval)
             WARN("GLX_SGI_swap_control extension is not available\n");
 
         if (ret)
-            swap_interval = interval;
+            gl->swap_interval = interval;
         else
             SetLastError(ERROR_DC_NOT_FOUND);
     }
 
+    release_gl_drawable(gl);
+
     return ret;
 }
 




More information about the wine-cvs mailing list