[PATCH v3] winex11.drv: Make the GL context current even if no drawables were given.
Charles Davis
cdavis5x at gmail.com
Tue Feb 23 22:12:55 CST 2016
Signed-off-by: Charles Davis <cdavis5x at gmail.com>
---
Try 3: Fix an assignment I missed. (Thanks, Ken.)
dlls/opengl32/tests/opengl.c | 2 +-
dlls/winex11.drv/opengl.c | 69 +++++++++++++++++++++++++-------------------
2 files changed, 41 insertions(+), 30 deletions(-)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c
index e5e1507..c058c19 100644
--- a/dlls/opengl32/tests/opengl.c
+++ b/dlls/opengl32/tests/opengl.c
@@ -975,7 +975,7 @@ static void test_opengl3(HDC hdc)
* expect drivers to ever offer it.
*/
res = wglMakeCurrent(0, gl3Ctx);
- ok(res == FALSE, "Wow, OpenGL 3.0 windowless rendering passed while it was expected not to!\n");
+ ok(res || broken(!res), "OpenGL 3.0 windowless rendering failed!\n");
if(res)
wglMakeCurrent(0, 0);
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 704d62a..43a7704 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -1823,6 +1823,7 @@ static BOOL glxdrv_wglMakeCurrent(HDC hdc, struct wgl_context *ctx)
{
BOOL ret = FALSE;
struct gl_drawable *gl;
+ Drawable drawable;
TRACE("(%p,%p)\n", hdc, ctx);
@@ -1833,7 +1834,15 @@ static BOOL glxdrv_wglMakeCurrent(HDC hdc, struct wgl_context *ctx)
return TRUE;
}
- if ((gl = get_gl_drawable( WindowFromDC( hdc ), hdc )))
+ if (!hdc)
+ {
+ TRACE("ctx %p\n", ctx->ctx);
+
+ gl = NULL;
+ drawable = None;
+ ret = pglXMakeCurrent(gdi_display, drawable, ctx->ctx);
+ }
+ else if ((gl = get_gl_drawable( WindowFromDC( hdc ), hdc )))
{
if (ctx->fmt != gl->format)
{
@@ -1845,20 +1854,23 @@ static BOOL glxdrv_wglMakeCurrent(HDC hdc, struct wgl_context *ctx)
TRACE("hdc %p drawable %lx fmt %p ctx %p %s\n", hdc, gl->drawable, gl->format, ctx->ctx,
debugstr_fbconfig( gl->format->fbconfig ));
- ret = pglXMakeCurrent(gdi_display, gl->drawable, ctx->ctx);
- if (ret)
- {
- NtCurrentTeb()->glContext = ctx;
- ctx->has_been_current = TRUE;
- ctx->hdc = hdc;
- ctx->drawables[0] = gl->drawable;
- ctx->drawables[1] = gl->drawable;
- ctx->refresh_drawables = FALSE;
- goto done;
- }
+ drawable = gl->drawable;
+ ret = pglXMakeCurrent(gdi_display, drawable, ctx->ctx);
}
- SetLastError( ERROR_INVALID_HANDLE );
+ else
+ ret = FALSE;
+ if (ret)
+ {
+ NtCurrentTeb()->glContext = ctx;
+ ctx->has_been_current = TRUE;
+ ctx->hdc = hdc;
+ ctx->drawables[0] = drawable;
+ ctx->drawables[1] = drawable;
+ ctx->refresh_drawables = FALSE;
+ }
+ else
+ SetLastError( ERROR_INVALID_HANDLE );
done:
release_gl_drawable( gl );
TRACE( "%p,%p returning %d\n", hdc, ctx, ret );
@@ -1884,24 +1896,23 @@ static BOOL X11DRV_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, struct
if (!pglXMakeContextCurrent) return FALSE;
- if ((draw_gl = get_gl_drawable( WindowFromDC( draw_hdc ), draw_hdc )))
+ draw_gl = get_gl_drawable( WindowFromDC( draw_hdc ), draw_hdc );
+ read_gl = get_gl_drawable( WindowFromDC( read_hdc ), read_hdc );
+
+ ret = pglXMakeContextCurrent(gdi_display, draw_gl ? draw_gl->drawable : 0,
+ read_gl ? read_gl->drawable : 0, ctx->ctx);
+ if (ret)
{
- read_gl = get_gl_drawable( WindowFromDC( read_hdc ), read_hdc );
- ret = pglXMakeContextCurrent(gdi_display, draw_gl->drawable,
- read_gl ? read_gl->drawable : 0, ctx->ctx);
- if (ret)
- {
- ctx->has_been_current = TRUE;
- ctx->hdc = draw_hdc;
- ctx->drawables[0] = draw_gl->drawable;
- ctx->drawables[1] = read_gl ? read_gl->drawable : 0;
- ctx->refresh_drawables = FALSE;
- NtCurrentTeb()->glContext = ctx;
- goto done;
- }
+ ctx->has_been_current = TRUE;
+ ctx->hdc = draw_hdc;
+ ctx->drawables[0] = draw_gl ? draw_gl->drawable : 0;
+ ctx->drawables[1] = read_gl ? read_gl->drawable : 0;
+ ctx->refresh_drawables = FALSE;
+ NtCurrentTeb()->glContext = ctx;
}
- SetLastError( ERROR_INVALID_HANDLE );
-done:
+ else
+ SetLastError( ERROR_INVALID_HANDLE );
+
release_gl_drawable( read_gl );
release_gl_drawable( draw_gl );
TRACE( "%p,%p,%p returning %d\n", draw_hdc, read_hdc, ctx, ret );
--
2.7.1
More information about the wine-patches
mailing list