summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-08-01 22:58:38 +0200
committerwm4 <wm4@nowhere>2014-08-01 23:03:52 +0200
commitaa46968ed057ee5176f06ae27bfc0c771f0b17ed (patch)
treeb0febbdf32ab316ebd37deaf4e967a6c5ce7e10a /video
parentbf5b1e9a0517b357b93ffaef7b6d96ad8b9917b0 (diff)
downloadmpv-aa46968ed057ee5176f06ae27bfc0c771f0b17ed.tar.bz2
mpv-aa46968ed057ee5176f06ae27bfc0c771f0b17ed.tar.xz
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.
Diffstat (limited to 'video')
-rw-r--r--video/out/gl_w32.c22
1 files changed, 10 insertions, 12 deletions
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;
}