Alexandre Julliard : winex11: Check for matching pixel format in wglMakeCurrent.
Alexandre Julliard
julliard at winehq.org
Thu Jun 19 06:37:02 CDT 2008
Module: wine
Branch: master
Commit: 815baba090b79cab4a3ceff5fa248bda1f7c8e8c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=815baba090b79cab4a3ceff5fa248bda1f7c8e8c
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Jun 18 20:10:47 2008 +0200
winex11: Check for matching pixel format in wglMakeCurrent.
---
dlls/opengl32/tests/opengl.c | 28 ++++++++++++++++++++++++++++
dlls/winex11.drv/opengl.c | 7 ++++++-
2 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c
index 46ded06..e72d1a0 100644
--- a/dlls/opengl32/tests/opengl.c
+++ b/dlls/opengl32/tests/opengl.c
@@ -265,6 +265,33 @@ static void test_setpixelformat(HDC winhdc)
}
}
+static void test_makecurrent(HDC winhdc)
+{
+ BOOL ret;
+ HGLRC hglrc;
+ HDC hdc;
+
+ hdc = GetDC(0);
+ ok( hdc != 0, "GetDC(0) failed\n" );
+
+ hglrc = wglCreateContext(winhdc);
+ ok( hglrc != 0, "wglCreateContext failed\n" );
+
+ ret = wglMakeCurrent( winhdc, hglrc );
+ ok( ret, "wglMakeCurrent failed\n" );
+
+ ok( wglGetCurrentContext() == hglrc, "wrong context\n" );
+
+ SetLastError( 0xdeadbeef );
+ ret = wglMakeCurrent( hdc, hglrc );
+ ok( !ret, "wglMakeCurrent succeeded\n" );
+ ok( GetLastError() == ERROR_INVALID_PIXEL_FORMAT, "last error %u\n", GetLastError() );
+
+ ok( wglGetCurrentContext() == hglrc, "wrong context\n" );
+
+ ReleaseDC( 0, hdc );
+}
+
static void test_colorbits(HDC hdc)
{
const int iAttribList[] = { WGL_COLOR_BITS_ARB, WGL_RED_BITS_ARB, WGL_GREEN_BITS_ARB,
@@ -437,6 +464,7 @@ START_TEST(opengl)
ok(res, "wglMakeCurrent failed!\n");
init_functions();
+ test_makecurrent(hdc);
test_setpixelformat(hdc);
test_colorbits(hdc);
test_gdi_dbuf(hdc);
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 393c11a..b6e88ea 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -1754,6 +1754,7 @@ BOOL X11DRV_wglMakeCurrent(X11DRV_PDEVICE *physDev, HGLRC hglrc) {
BOOL ret;
HDC hdc = physDev->hdc;
DWORD type = GetObjectType(hdc);
+ Wine_GLContext *ctx = (Wine_GLContext *) hglrc;
TRACE("(%p,%p)\n", hdc, hglrc);
@@ -1766,8 +1767,12 @@ BOOL X11DRV_wglMakeCurrent(X11DRV_PDEVICE *physDev, HGLRC hglrc) {
if (hglrc == NULL) {
ret = pglXMakeCurrent(gdi_display, None, NULL);
NtCurrentTeb()->glContext = NULL;
+ } else if (ctx->fmt->iPixelFormat != physDev->current_pf) {
+ WARN( "mismatched pixel format hdc %p %u ctx %p %u\n",
+ hdc, physDev->current_pf, ctx, ctx->fmt->iPixelFormat );
+ SetLastError( ERROR_INVALID_PIXEL_FORMAT );
+ ret = FALSE;
} else {
- Wine_GLContext *ctx = (Wine_GLContext *) hglrc;
Drawable drawable = get_glxdrawable(physDev);
if (ctx->ctx == NULL) {
/* The describe lines below are for debugging purposes only */
More information about the wine-cvs
mailing list