Module: wine Branch: master Commit: 1cbc85c436ee82e8bbe86bb938aa75463aec6620 URL: https://gitlab.winehq.org/wine/wine/-/commit/1cbc85c436ee82e8bbe86bb938aa754...
Author: Zhiyi Zhang zzhang@codeweavers.com Date: Thu Apr 11 14:57:48 2024 +0800
opengl32/tests: Add default framebuffer tests.
---
dlls/opengl32/tests/opengl.c | 92 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index 74aff6b4bbd..7647ae6aa11 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -53,8 +53,29 @@ static void (WINAPI *pglDebugMessageCallbackARB)(void *, void *); static void (WINAPI *pglDebugMessageControlARB)(GLenum, GLenum, GLenum, GLsizei, const GLuint *, GLboolean); static void (WINAPI *pglDebugMessageInsertARB)(GLenum, GLenum, GLuint, GLenum, GLsizei, const char *);
+/* GL_ARB_framebuffer_object */ +static void (WINAPI *pglBindFramebuffer)(GLenum target, GLuint framebuffer); +static GLenum (WINAPI *pglCheckFramebufferStatus)(GLenum target); + static const char* wgl_extensions = NULL;
+static void flush_events(void) +{ + MSG msg; + int diff = 200; + int min_timeout = 100; + DWORD time = GetTickCount() + diff; + + while (diff > 0) + { + if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT) + break; + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) + DispatchMessageA(&msg); + diff = time - GetTickCount(); + } +} + static void init_functions(void) { #define GET_PROC(func) \ @@ -90,6 +111,10 @@ static void init_functions(void) GET_PROC(glDebugMessageControlARB) GET_PROC(glDebugMessageInsertARB)
+ /* GL_ARB_framebuffer_object */ + GET_PROC(glBindFramebuffer) + GET_PROC(glCheckFramebufferStatus) + #undef GET_PROC }
@@ -1335,6 +1360,72 @@ static void test_minimized(void) DestroyWindow(window); }
+static void test_framebuffer(void) +{ + static const PIXELFORMATDESCRIPTOR pf_desc = + { + sizeof(PIXELFORMATDESCRIPTOR), + 1, /* version */ + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, + PFD_TYPE_RGBA, + 24, /* 24-bit color depth */ + 0, 0, 0, 0, 0, 0, /* color bits */ + 0, /* alpha buffer */ + 0, /* shift bit */ + 0, /* accumulation buffer */ + 0, 0, 0, 0, /* accum bits */ + 32, /* z-buffer */ + 0, /* stencil buffer */ + 0, /* auxiliary buffer */ + PFD_MAIN_PLANE, /* main layer */ + 0, /* reserved */ + 0, 0, 0 /* layer masks */ + }; + int pixel_format; + GLenum status; + HWND window; + HGLRC ctx; + BOOL ret; + HDC dc; + + /* Test the default framebuffer status for a window that becomes visible after wglMakeCurrent() */ + window = CreateWindowA("static", "opengl32_test", WS_POPUP, 0, 0, 640, 480, 0, 0, 0, 0); + ok(!!window, "Failed to create window, last error %#lx.\n", GetLastError()); + dc = GetDC(window); + ok(!!dc, "Failed to get DC.\n"); + pixel_format = ChoosePixelFormat(dc, &pf_desc); + if (!pixel_format) + { + win_skip("Failed to find pixel format.\n"); + ReleaseDC(window, dc); + DestroyWindow(window); + return; + } + + ret = SetPixelFormat(dc, pixel_format, &pf_desc); + ok(ret, "Failed to set pixel format, last error %#lx.\n", GetLastError()); + ctx = wglCreateContext(dc); + ok(!!ctx, "Failed to create GL context, last error %#lx.\n", GetLastError()); + ret = wglMakeCurrent(dc, ctx); + ok(ret, "Failed to make context current, last error %#lx.\n", GetLastError()); + + ShowWindow(window, SW_SHOW); + flush_events(); + + pglBindFramebuffer(GL_FRAMEBUFFER, 0); + + status = pglCheckFramebufferStatus(GL_FRAMEBUFFER); + todo_wine_if(status == GL_FRAMEBUFFER_UNDEFINED) /* macOS */ + ok(status == GL_FRAMEBUFFER_COMPLETE, "Expected %#x, got %#x.\n", GL_FRAMEBUFFER_COMPLETE, status); + + ret = wglMakeCurrent(NULL, NULL); + ok(ret, "Failed to clear current context, last error %#lx.\n", GetLastError()); + ret = wglDeleteContext(ctx); + ok(ret, "Failed to delete GL context, last error %#lx.\n", GetLastError()); + ReleaseDC(window, dc); + DestroyWindow(window); +} + static void test_window_dc(void) { PIXELFORMATDESCRIPTOR pf_desc = @@ -2162,6 +2253,7 @@ START_TEST(opengl) test_colorbits(hdc); test_gdi_dbuf(hdc); test_acceleration(hdc); + test_framebuffer();
wgl_extensions = pwglGetExtensionsStringARB(hdc); if(wgl_extensions == NULL) skip("Skipping opengl32 tests because this OpenGL implementation doesn't support WGL extensions!\n");