From 8e45c4c6146f3935fed1317d82b4396dd94fe632 Mon Sep 17 00:00:00 2001 From: Alexander Gottwald Date: Fri, 12 Mar 2004 12:20:42 +0000 Subject: [PATCH] attach the gl context to the active window. still a hack but works better than before (at least for multiwindow) --- GL/windows/indirect.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/GL/windows/indirect.c b/GL/windows/indirect.c index a9a158cc9..e977b17d0 100755 --- a/GL/windows/indirect.c +++ b/GL/windows/indirect.c @@ -162,6 +162,9 @@ static struct __GLdispatchStateRec* glWinDispatchExec(__GLcontext *gc); static void glWinBeginDispatchOverride(__GLcontext *gc); static void glWinEndDispatchOverride(__GLcontext *gc); +/* Debug output */ +static void pfdOut(const PIXELFORMATDESCRIPTOR *pfd); + static __GLexports glWinExports = { glWinDestroyContext, glWinLoseCurrent, @@ -252,6 +255,32 @@ static void unattach(__GLcontext *gc) static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv) { GLWIN_DEBUG_MSG("attach %p\n", gc); + HDC dc; + PIXELFORMATDESCRIPTOR pfd; + BOOL ret; + + ret = wglDeleteContext(gc->ctx); + if (!ret) { + ErrorF("wglDeleteContext error: %s\n", winErrorMessage()); + } + + /* get the correct window handle */ + gc->wnd = GetActiveWindow(); /* FIXME */ + + dc = GetDC(gc->wnd); + DescribePixelFormat(dc, gc->pixelFormat, + sizeof(pfd), &pfd); + pfdOut(&pfd); + ret = SetPixelFormat(dc, gc->pixelFormat, &pfd); + + gc->ctx = wglCreateContext(dc); + + if (gc->ctx == NULL) { + ErrorF("wglCreateContext error: %s\n", winErrorMessage()); + ReleaseDC(gc->wnd, dc); + return; + } + ReleaseDC(gc->wnd, dc); } static GLboolean glWinMakeCurrent(__GLcontext *gc)