Commit 5115f55e authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Use WGL_ARB_create_context when available.

parent 147765a5
...@@ -1266,11 +1266,11 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, ...@@ -1266,11 +1266,11 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
const struct wined3d_format *color_format; const struct wined3d_format *color_format;
struct wined3d_context *ret; struct wined3d_context *ret;
BOOL auxBuffers = FALSE; BOOL auxBuffers = FALSE;
HGLRC ctx, share_ctx;
int pixel_format; int pixel_format;
unsigned int s; unsigned int s;
int swap_interval; int swap_interval;
DWORD state; DWORD state;
HGLRC ctx;
HDC hdc; HDC hdc;
TRACE("swapchain %p, target %p, window %p.\n", swapchain, target, swapchain->win_handle); TRACE("swapchain %p, target %p, window %p.\n", swapchain, target, swapchain->win_handle);
...@@ -1367,19 +1367,28 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, ...@@ -1367,19 +1367,28 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
goto out; goto out;
} }
if (!(ctx = wglCreateContext(hdc))) share_ctx = device->context_count ? device->contexts[0]->glCtx : NULL;
if (gl_info->p_wglCreateContextAttribsARB)
{ {
ERR("Failed to create a WGL context.\n"); if (!(ctx = gl_info->p_wglCreateContextAttribsARB(hdc, share_ctx, NULL)))
context_release(ret); {
goto out; ERR("Failed to create a WGL context.\n");
context_release(ret);
goto out;
}
} }
else
if (device->context_count)
{ {
if (!wglShareLists(device->contexts[0]->glCtx, ctx)) if (!(ctx = wglCreateContext(hdc)))
{
ERR("Failed to create a WGL context.\n");
context_release(ret);
goto out;
}
if (share_ctx && !wglShareLists(share_ctx, ctx))
{ {
ERR("wglShareLists(%p, %p) failed, last error %#x.\n", ERR("wglShareLists(%p, %p) failed, last error %#x.\n", share_ctx, ctx, GetLastError());
device->contexts[0]->glCtx, ctx, GetLastError());
context_release(ret); context_release(ret);
if (!wglDeleteContext(ctx)) if (!wglDeleteContext(ctx))
ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx, GetLastError()); ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx, GetLastError());
......
...@@ -296,6 +296,35 @@ static void WineD3D_ReleaseFakeGLContext(const struct wined3d_fake_gl_ctx *ctx) ...@@ -296,6 +296,35 @@ static void WineD3D_ReleaseFakeGLContext(const struct wined3d_fake_gl_ctx *ctx)
ERR("Failed to restore previous GL context.\n"); ERR("Failed to restore previous GL context.\n");
} }
static void wined3d_create_fake_gl_context_attribs(struct wined3d_fake_gl_ctx *fake_gl_ctx,
struct wined3d_gl_info *gl_info)
{
HGLRC new_ctx;
if (!(gl_info->p_wglCreateContextAttribsARB = (void *)wglGetProcAddress("wglCreateContextAttribsARB")))
return;
if (!(new_ctx = gl_info->p_wglCreateContextAttribsARB(fake_gl_ctx->dc, NULL, NULL)))
{
ERR("Failed to create a context using wglCreateContextAttribsARB(), last error %#x.\n", GetLastError());
gl_info->p_wglCreateContextAttribsARB = NULL;
return;
}
if (!wglMakeCurrent(fake_gl_ctx->dc, new_ctx))
{
ERR("Failed to make new context current, last error %#x.\n", GetLastError());
if (!wglDeleteContext(new_ctx))
ERR("Failed to delete new context, last error %#x.\n", GetLastError());
gl_info->p_wglCreateContextAttribsARB = NULL;
return;
}
if (!wglDeleteContext(fake_gl_ctx->gl_ctx))
ERR("Failed to delete old context, last error %#x.\n", GetLastError());
fake_gl_ctx->gl_ctx = new_ctx;
}
/* Do not call while under the GL lock. */ /* Do not call while under the GL lock. */
static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx) static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
{ {
...@@ -4919,6 +4948,8 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal) ...@@ -4919,6 +4948,8 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal)
return FALSE; return FALSE;
} }
wined3d_create_fake_gl_context_attribs(&fake_gl_ctx, gl_info);
if (!wined3d_adapter_init_gl_caps(adapter)) if (!wined3d_adapter_init_gl_caps(adapter))
{ {
ERR("Failed to initialize GL caps for adapter %p.\n", adapter); ERR("Failed to initialize GL caps for adapter %p.\n", adapter);
......
...@@ -1552,6 +1552,7 @@ struct wined3d_gl_info ...@@ -1552,6 +1552,7 @@ struct wined3d_gl_info
BOOL supported[WINED3D_GL_EXT_COUNT]; BOOL supported[WINED3D_GL_EXT_COUNT];
GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP + 1]; GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP + 1];
HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs);
struct opengl_funcs gl_ops; struct opengl_funcs gl_ops;
struct wined3d_fbo_ops fbo_ops; struct wined3d_fbo_ops fbo_ops;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment