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
This commit is contained in:
Zhiyi Zhang 2023-02-02 10:34:17 +08:00 committed by Alexandre Julliard
parent 2fbe1f3508
commit 7937596f8f

View file

@ -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)