From aa46968ed057ee5176f06ae27bfc0c771f0b17ed Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 1 Aug 2014 22:58:38 +0200 Subject: win32: fix assertion failure If OpenGL 3.x doesn't work, the fallback to legacy GL will call the function to create the DC again, and it will assert. Just make it not to, and also simplify the code a bit. Fixes #974. --- video/out/gl_w32.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'video') diff --git a/video/out/gl_w32.c b/video/out/gl_w32.c index 9d704bcca6..13a46a295d 100644 --- a/video/out/gl_w32.c +++ b/video/out/gl_w32.c @@ -34,7 +34,8 @@ static bool create_dc(struct MPGLContext *ctx, int flags) struct w32_context *w32_ctx = ctx->priv; HWND win = vo_w32_hwnd(ctx->vo); - assert(!w32_ctx->hdc); + if (w32_ctx->hdc) + return true; HDC hdc = GetDC(win); if (!hdc) @@ -83,7 +84,7 @@ static void *w32gpa(const GLubyte *procName) return GetProcAddress(oglmod, procName); } -static bool create_context_w32_old(struct MPGLContext *ctx, int flags) +static bool create_context_w32_old(struct MPGLContext *ctx) { struct w32_context *w32_ctx = ctx->priv; HGLRC *context = &w32_ctx->context; @@ -91,9 +92,6 @@ static bool create_context_w32_old(struct MPGLContext *ctx, int flags) if (*context) return true; - if (!create_dc(ctx, flags)) - return false; - HDC windc = w32_ctx->hdc; bool res = false; @@ -118,7 +116,7 @@ out: return res; } -static bool create_context_w32_gl3(struct MPGLContext *ctx, int flags) +static bool create_context_w32_gl3(struct MPGLContext *ctx) { struct w32_context *w32_ctx = ctx->priv; HGLRC *context = &w32_ctx->context; @@ -126,9 +124,6 @@ static bool create_context_w32_gl3(struct MPGLContext *ctx, int flags) if (*context) // reuse existing context return true; // not reusing it breaks gl3! - if (!create_dc(ctx, flags)) - return false; - HDC windc = w32_ctx->hdc; HGLRC new_context = 0; @@ -199,7 +194,7 @@ static bool create_context_w32_gl3(struct MPGLContext *ctx, int flags) return true; unsupported: - MP_ERR(ctx->vo, "The current OpenGL implementation does not support OpenGL 3.x \n"); + MP_ERR(ctx->vo, "The OpenGL driver does not support OpenGL 3.x \n"); out: wglDeleteContext(new_context); return false; @@ -210,11 +205,14 @@ static bool config_window_w32(struct MPGLContext *ctx, int flags) if (!vo_w32_config(ctx->vo, flags)) return false; + if (!create_dc(ctx, flags)) + return false; + bool success = false; if (ctx->requested_gl_version >= MPGL_VER(3, 0)) - success = create_context_w32_gl3(ctx, flags); + success = create_context_w32_gl3(ctx); if (!success) - success = create_context_w32_old(ctx, flags); + success = create_context_w32_old(ctx); return success; } -- cgit v1.2.3