Module: wine Branch: master Commit: 323d9e428c02aa2f3ae5b637ae1f16fad27e431c URL: http://source.winehq.org/git/wine.git/?a=commit;h=323d9e428c02aa2f3ae5b637ae...
Author: Roderick Colenbrander thunderbird2k@gmx.net Date: Wed Aug 1 15:58:51 2007 +0200
wgl: SetPixelFormat should fail on the root window.
---
dlls/opengl32/tests/opengl.c | 39 +++++++++++++++++++++++++++++++++++++++ dlls/winex11.drv/opengl.c | 7 +++++++ 2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index ca2710c..17ca54a 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -151,6 +151,43 @@ static void test_pbuffers(HDC hdc) else skip("Pbuffer test for offscreen pixelformat skipped as no offscreen-only format with pbuffer capabilities has been found\n"); }
+static void test_setpixelformat(void) +{ + int res = 0; + int pf; + PIXELFORMATDESCRIPTOR pfd = { + 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 */ + }; + + HDC hdc = GetDC(0); + ok(hdc != 0, "GetDC(0) failed!\n"); + + /* This should pass even on the main device context */ + pf = ChoosePixelFormat(hdc, &pfd); + ok(pf != 0, "ChoosePixelFormat failed on main device context"); + + /* SetPixelFormat on the main device context 'X root window' should fail */ + res = SetPixelFormat(hdc, pf, &pfd); + ok(res == 0, "SetPixelFormat on main device context should fail\n"); +} + START_TEST(opengl) { HWND hwnd; @@ -198,6 +235,8 @@ START_TEST(opengl) ok(res, "wglMakeCurrent failed!\n"); init_functions();
+ test_setpixelformat(); + wgl_extensions = pwglGetExtensionsStringARB(hdc); if(wgl_extensions == NULL) skip("Skipping opengl32 tests because this OpenGL implementation doesn't support WGL extensions!\n");
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 265e67f..b3cbeef 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1298,6 +1298,13 @@ BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev, return 0; }
+ /* SetPixelFormat is not allowed on the X root_window e.g. GetDC(0) */ + if(get_glxdrawable(physDev) == root_window) + { + ERR("Invalid operation on root_window\n"); + return 0; + } + /* Check if iPixelFormat is in our list of supported formats to see if it is supported. */ fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &value); if(!fmt) {