wined3d: Link directly to opengl32.

This commit is contained in:
Alexandre Julliard 2012-11-08 11:56:06 +01:00
parent e40b2a1b07
commit 449deda62f
4 changed files with 33 additions and 62 deletions

View File

@ -1,6 +1,6 @@
MODULE = wined3d.dll
IMPORTLIB = wined3d
IMPORTS = uuid user32 gdi32 advapi32
IMPORTS = uuid opengl32 user32 gdi32 advapi32
C_SRCS = \
arb_program_shader.c \

View File

@ -771,7 +771,7 @@ static BOOL context_set_gl_context(struct wined3d_context *ctx)
backup = TRUE;
}
if (backup || !pwglMakeCurrent(ctx->hdc, ctx->glCtx))
if (backup || !wglMakeCurrent(ctx->hdc, ctx->glCtx))
{
HDC dc;
@ -805,7 +805,7 @@ static BOOL context_set_gl_context(struct wined3d_context *ctx)
return FALSE;
}
if (!pwglMakeCurrent(dc, ctx->glCtx))
if (!wglMakeCurrent(dc, ctx->glCtx))
{
ERR("Fallback to backup window (dc %p) failed too, last error %#x.\n",
dc, GetLastError());
@ -825,7 +825,7 @@ static void context_restore_gl_context(const struct wined3d_gl_info *gl_info, HD
return;
}
if (!pwglMakeCurrent(dc, gl_ctx))
if (!wglMakeCurrent(dc, gl_ctx))
{
ERR("Failed to restore GL context %p on device context %p, last error %#x.\n",
gl_ctx, dc, GetLastError());
@ -897,8 +897,8 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
unsigned int i;
int restore_pf;
restore_ctx = pwglGetCurrentContext();
restore_dc = pwglGetCurrentDC();
restore_ctx = wglGetCurrentContext();
restore_dc = wglGetCurrentDC();
restore_pf = GetPixelFormat(restore_dc);
if (context->valid && restore_ctx != context->glCtx)
@ -984,14 +984,14 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
{
context_restore_gl_context(gl_info, restore_dc, restore_ctx, restore_pf);
}
else if (pwglGetCurrentContext() && !pwglMakeCurrent(NULL, NULL))
else if (wglGetCurrentContext() && !wglMakeCurrent(NULL, NULL))
{
ERR("Failed to disable GL context.\n");
}
ReleaseDC(context->win_handle, context->hdc);
if (!pwglDeleteContext(context->glCtx))
if (!wglDeleteContext(context->glCtx))
{
DWORD err = GetLastError();
ERR("wglDeleteContext(%p) failed, last error %#x.\n", context->glCtx, err);
@ -1052,10 +1052,10 @@ BOOL context_set_current(struct wined3d_context *ctx)
return FALSE;
ctx->current = 1;
}
else if(pwglGetCurrentContext())
else if(wglGetCurrentContext())
{
TRACE("Clearing current D3D context.\n");
if (!pwglMakeCurrent(NULL, NULL))
if (!wglMakeCurrent(NULL, NULL))
{
DWORD err = GetLastError();
ERR("Failed to clear current GL context, last error %#x.\n", err);
@ -1095,14 +1095,14 @@ static void context_enter(struct wined3d_context *context)
if (!context->level++)
{
const struct wined3d_context *current_context = context_get_current();
HGLRC current_gl = pwglGetCurrentContext();
HGLRC current_gl = wglGetCurrentContext();
if (current_gl && (!current_context || current_context->glCtx != current_gl))
{
TRACE("Another GL context (%p on device context %p) is already current.\n",
current_gl, pwglGetCurrentDC());
current_gl, wglGetCurrentDC());
context->restore_ctx = current_gl;
context->restore_dc = pwglGetCurrentDC();
context->restore_dc = wglGetCurrentDC();
context->restore_pf = GetPixelFormat(context->restore_dc);
}
}
@ -1380,7 +1380,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
goto out;
}
if (!(ctx = pwglCreateContext(hdc)))
if (!(ctx = wglCreateContext(hdc)))
{
ERR("Failed to create a WGL context.\n");
context_release(ret);
@ -1389,12 +1389,12 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
if (device->context_count)
{
if (!pwglShareLists(device->contexts[0]->glCtx, ctx))
if (!wglShareLists(device->contexts[0]->glCtx, ctx))
{
ERR("wglShareLists(%p, %p) failed, last error %#x.\n",
device->contexts[0]->glCtx, ctx, GetLastError());
context_release(ret);
if (!pwglDeleteContext(ctx))
if (!wglDeleteContext(ctx))
ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx, GetLastError());
goto out;
}
@ -1404,7 +1404,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
{
ERR("Failed to add the newly created context to the context list\n");
context_release(ret);
if (!pwglDeleteContext(ctx))
if (!wglDeleteContext(ctx))
ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx, GetLastError());
goto out;
}
@ -1439,7 +1439,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
ERR("Cannot activate context to set up defaults.\n");
device_context_remove(device, ret);
context_release(ret);
if (!pwglDeleteContext(ctx))
if (!wglDeleteContext(ctx))
ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx, GetLastError());
goto out;
}

View File

@ -277,10 +277,10 @@ static void WineD3D_ReleaseFakeGLContext(const struct wined3d_fake_gl_ctx *ctx)
{
TRACE("Destroying fake GL context.\n");
if (!pwglMakeCurrent(NULL, NULL))
if (!wglMakeCurrent(NULL, NULL))
ERR("Failed to disable fake GL context.\n");
if (!pwglDeleteContext(ctx->gl_ctx))
if (!wglDeleteContext(ctx->gl_ctx))
{
DWORD err = GetLastError();
ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx->gl_ctx, err);
@ -289,7 +289,7 @@ static void WineD3D_ReleaseFakeGLContext(const struct wined3d_fake_gl_ctx *ctx)
ReleaseDC(ctx->wnd, ctx->dc);
DestroyWindow(ctx->wnd);
if (ctx->restore_gl_ctx && !pwglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
ERR("Failed to restore previous GL context.\n");
}
@ -301,8 +301,8 @@ static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
TRACE("getting context...\n");
ctx->restore_dc = pwglGetCurrentDC();
ctx->restore_gl_ctx = pwglGetCurrentContext();
ctx->restore_dc = wglGetCurrentDC();
ctx->restore_gl_ctx = wglGetCurrentContext();
/* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
ctx->wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
@ -339,14 +339,14 @@ static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
SetPixelFormat(ctx->dc, iPixelFormat, &pfd);
/* Create a GL context. */
if (!(ctx->gl_ctx = pwglCreateContext(ctx->dc)))
if (!(ctx->gl_ctx = wglCreateContext(ctx->dc)))
{
WARN("Failed to create default context for capabilities initialization.\n");
goto fail;
}
/* Make it the current GL context. */
if (!pwglMakeCurrent(ctx->dc, ctx->gl_ctx))
if (!wglMakeCurrent(ctx->dc, ctx->gl_ctx))
{
ERR("Failed to make fake GL context current.\n");
goto fail;
@ -355,13 +355,13 @@ static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
return TRUE;
fail:
if (ctx->gl_ctx) pwglDeleteContext(ctx->gl_ctx);
if (ctx->gl_ctx) wglDeleteContext(ctx->gl_ctx);
ctx->gl_ctx = NULL;
if (ctx->dc) ReleaseDC(ctx->wnd, ctx->dc);
ctx->dc = NULL;
if (ctx->wnd) DestroyWindow(ctx->wnd);
ctx->wnd = NULL;
if (ctx->restore_gl_ctx && !pwglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
ERR("Failed to restore previous GL context.\n");
return FALSE;
@ -2363,7 +2363,7 @@ static void parse_extension_string(struct wined3d_gl_info *gl_info, const char *
static void load_gl_funcs(struct wined3d_gl_info *gl_info)
{
#define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)pwglGetProcAddress(#pfn);
#define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)wglGetProcAddress(#pfn);
GL_EXT_FUNCS_GEN;
#undef USE_GL_FUNC
@ -2652,7 +2652,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
/* Now work out what GL support this card really has. */
load_gl_funcs( gl_info );
hdc = pwglGetCurrentDC();
hdc = wglGetCurrentDC();
/* Not all GL drivers might offer WGL extensions e.g. VirtualBox. */
if (GL_EXTCALL(wglGetExtensionsStringARB))
WGL_Extensions = (const char *)GL_EXTCALL(wglGetExtensionsStringARB(hdc));
@ -5436,7 +5436,6 @@ static BOOL InitAdapters(struct wined3d *wined3d)
{
struct wined3d_adapter *adapter = &wined3d->adapters[0];
struct wined3d_gl_info *gl_info = &adapter->gl_info;
static HMODULE mod_gl;
BOOL ret;
int ps_selected_mode, vs_selected_mode;
@ -5446,24 +5445,14 @@ static BOOL InitAdapters(struct wined3d *wined3d)
TRACE("Initializing adapters\n");
if(!mod_gl) {
mod_gl = LoadLibraryA("opengl32.dll");
if(!mod_gl) {
ERR("Can't load opengl32.dll!\n");
goto nogl_adapter;
}
}
/* Load WGL core functions from opengl32.dll */
#define USE_WGL_FUNC(pfn) p##pfn = (void*)GetProcAddress(mod_gl, #pfn);
WGL_FUNCS_GEN;
#undef USE_WGL_FUNC
/* Dynamically load all GL core functions */
#ifdef USE_WIN32_OPENGL
{
HMODULE mod_gl = GetModuleHandleA("opengl32.dll");
#define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
ALL_WGL_FUNCS
#undef USE_GL_FUNC
}
#else
/* To bypass the opengl32 thunks retrieve functions from the WGL driver instead of opengl32 */
{

View File

@ -31,24 +31,6 @@
void (WINE_GLAPI *glDisableWINE)(GLenum cap) DECLSPEC_HIDDEN;
void (WINE_GLAPI *glEnableWINE)(GLenum cap) DECLSPEC_HIDDEN;
/* WGL functions */
HGLRC (WINAPI *pwglCreateContext)(HDC) DECLSPEC_HIDDEN;
BOOL (WINAPI *pwglDeleteContext)(HGLRC) DECLSPEC_HIDDEN;
HGLRC (WINAPI *pwglGetCurrentContext)(void) DECLSPEC_HIDDEN;
HDC (WINAPI *pwglGetCurrentDC)(void) DECLSPEC_HIDDEN;
PROC (WINAPI *pwglGetProcAddress)(LPCSTR) DECLSPEC_HIDDEN;
BOOL (WINAPI *pwglMakeCurrent)(HDC, HGLRC) DECLSPEC_HIDDEN;
BOOL (WINAPI *pwglShareLists)(HGLRC, HGLRC) DECLSPEC_HIDDEN;
#define WGL_FUNCS_GEN \
USE_WGL_FUNC(wglCreateContext) \
USE_WGL_FUNC(wglDeleteContext) \
USE_WGL_FUNC(wglGetCurrentContext) \
USE_WGL_FUNC(wglGetCurrentDC) \
USE_WGL_FUNC(wglGetProcAddress) \
USE_WGL_FUNC(wglMakeCurrent) \
USE_WGL_FUNC(wglShareLists)
/* OpenGL extensions. */
enum wined3d_gl_extension
{