Module: wine Branch: master Commit: 7937596f8fb2a7aef3b61e93ee0c1e3f0062e80c URL: https://gitlab.winehq.org/wine/wine/-/commit/7937596f8fb2a7aef3b61e93ee0c1e3... Author: Zhiyi Zhang <zzhang(a)codeweavers.com> Date: Thu Feb 2 10:34:17 2023 +0800 opengl32/tests: Make context current before calling wglCopyContext(). Otherwise, wglCopyContext() crashes on Windows with a NVIDIA GPU and fails on Windows with a AMD GPU. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51311 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54103 --- dlls/opengl32/tests/opengl.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index 42c2626a2c2..6979e00792e 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -1899,11 +1899,16 @@ static void test_wglChoosePixelFormatARB(HDC hdc) static void test_copy_context(HDC hdc) { - HGLRC ctx, ctx2; + HGLRC ctx, ctx2, old_ctx; BOOL ret; + old_ctx = wglGetCurrentContext(); + ok(!!old_ctx, "wglGetCurrentContext failed, last error %#lx.\n", GetLastError()); + ctx = wglCreateContext(hdc); ok(!!ctx, "Failed to create GL context, last error %#lx.\n", GetLastError()); + ret = wglMakeCurrent(hdc, ctx); + ok(ret, "wglMakeCurrent failed, last error %#lx.\n", GetLastError()); ctx2 = wglCreateContext(hdc); ok(!!ctx2, "Failed to create GL context, last error %#lx.\n", GetLastError()); @@ -1911,10 +1916,15 @@ static void test_copy_context(HDC hdc) todo_wine ok(ret, "Failed to copy GL context, last error %#lx.\n", GetLastError()); + ret = wglMakeCurrent(NULL, NULL); + ok(ret, "wglMakeCurrent failed, last error %#lx.\n", GetLastError()); ret = wglDeleteContext(ctx2); ok(ret, "Failed to delete GL context, last error %#lx.\n", GetLastError()); ret = wglDeleteContext(ctx); ok(ret, "Failed to delete GL context, last error %#lx.\n", GetLastError()); + + ret = wglMakeCurrent(hdc, old_ctx); + ok(ret, "wglMakeCurrent failed, last error %#lx.\n", GetLastError()); } START_TEST(opengl)