Commit edfc7f0d authored by Alexandre Julliard's avatar Alexandre Julliard

opengl32: Move wglGetProcAddress to the WGL driver.

parent 8a13afed
......@@ -497,11 +497,6 @@
@ stub pstackConnect
################################################################
# Wine extensions: OpenGL support
#
@ stdcall -private wglGetProcAddress(str)
################################################################
# Wine extensions: Win16 functions that are needed by other dlls
#
@ stdcall GetDCHook(long ptr)
......
......@@ -46,46 +46,6 @@ static INT (WINAPI *wglGetPixelFormat)(HDC);
static BOOL (WINAPI *wglSetPixelFormat)(HDC,INT,const PIXELFORMATDESCRIPTOR*);
static BOOL (WINAPI *wglSwapBuffers)(HDC);
static HDC default_hdc = 0;
/* We route all wgl functions from opengl32.dll through gdi32.dll to
* the display driver. Various wgl calls have a hDC as one of their parameters.
* Using get_dc_ptr we get access to the functions exported by the driver.
* Some functions don't receive a hDC. This function creates a global hdc and
* if there's already a global hdc, it returns it.
*/
static DC* OPENGL_GetDefaultDC(void)
{
if(!default_hdc)
default_hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
return get_dc_ptr(default_hdc);
}
/***********************************************************************
* Internal wglGetProcAddress for retrieving WGL extensions
*/
PROC WINAPI wglGetProcAddress(LPCSTR func)
{
PROC ret = NULL;
DC *dc;
if(!func)
return NULL;
TRACE("func: '%s'\n", func);
/* Retrieve the global hDC to get access to the driver. */
dc = OPENGL_GetDefaultDC();
if (dc)
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pwglGetProcAddress );
ret = physdev->funcs->pwglGetProcAddress(func);
release_dc_ptr( dc );
}
return ret;
}
/***********************************************************************
* __wine_get_wgl_driver (GDI32.@)
*/
......
......@@ -48,8 +48,6 @@ WINE_DECLARE_DEBUG_CHANNEL(opengl);
static struct
{
PROC (WINAPI *p_wglGetProcAddress)(LPCSTR lpszProc);
/* internal WGL functions */
void (WINAPI *p_wglFinish)(void);
void (WINAPI *p_wglFlush)(void);
......@@ -508,7 +506,7 @@ PROC WINAPI wglGetProcAddress(LPCSTR lpszProc) {
/* If the function name starts with a 'w', it is a WGL extension */
if(lpszProc[0] == 'w')
{
local_func = wine_wgl.p_wglGetProcAddress( lpszProc );
local_func = wgl_driver->p_wglGetProcAddress( lpszProc );
if (local_func == (void *)1) /* special function that needs a wrapper */
{
ext_ret = bsearch( &ext, wgl_extensions, sizeof(wgl_extensions)/sizeof(wgl_extensions[0]),
......@@ -531,7 +529,7 @@ PROC WINAPI wglGetProcAddress(LPCSTR lpszProc) {
WARN("Extension '%s' required by function '%s' not supported!\n", ext_ret->extension, lpszProc);
}
local_func = wine_wgl.p_wglGetProcAddress(ext_ret->name);
local_func = wgl_driver->p_wglGetProcAddress(ext_ret->name);
/* After that, look at the extensions defined in the Linux OpenGL library */
if (local_func == NULL) {
......@@ -1113,27 +1111,16 @@ BOOL WINAPI DECLSPEC_HOTPATCH wglSwapBuffers( HDC hdc )
creating a rendering context.... */
static BOOL process_attach(void)
{
HMODULE mod_gdi32;
HDC hdc = GetDC( 0 );
wgl_driver = __wine_get_wgl_driver( hdc, WINE_GDI_DRIVER_VERSION );
ReleaseDC( 0, hdc );
mod_gdi32 = GetModuleHandleA( "gdi32.dll" );
if (!mod_gdi32)
{
ERR("GDI32 not loaded. Cannot create default context.\n");
return FALSE;
}
wine_wgl.p_wglGetProcAddress = (void *)GetProcAddress(mod_gdi32, "wglGetProcAddress");
/* internal WGL functions */
wine_wgl.p_wglFinish = (void *)wine_wgl.p_wglGetProcAddress("wglFinish");
wine_wgl.p_wglFlush = (void *)wine_wgl.p_wglGetProcAddress("wglFlush");
wine_wgl.p_wglGetCurrentContext = (void *)wine_wgl.p_wglGetProcAddress("wglGetCurrentContext");
wine_wgl.p_wglGetIntegerv = (void *)wine_wgl.p_wglGetProcAddress("wglGetIntegerv");
wine_wgl.p_wglFinish = (void *)wgl_driver->p_wglGetProcAddress("wglFinish");
wine_wgl.p_wglFlush = (void *)wgl_driver->p_wglGetProcAddress("wglFlush");
wine_wgl.p_wglGetCurrentContext = (void *)wgl_driver->p_wglGetProcAddress("wglGetCurrentContext");
wine_wgl.p_wglGetIntegerv = (void *)wgl_driver->p_wglGetProcAddress("wglGetIntegerv");
return TRUE;
}
......
......@@ -27,6 +27,9 @@
#include <stdio.h>
#include "wined3d_private.h"
#ifndef USE_WIN32_OPENGL
#include "wine/gdi_driver.h"
#endif
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
......@@ -5386,15 +5389,15 @@ static BOOL InitAdapters(struct wined3d *wined3d)
#define USE_GL_FUNC(pfn) pfn = (void*)GetProcAddress(mod_gl, #pfn);
#else
/* To bypass the opengl32 thunks load wglGetProcAddress from gdi32 instead of opengl32 */
pwglGetProcAddress = (void*)GetProcAddress(GetModuleHandleA("gdi32.dll"), "wglGetProcAddress");
{
HDC hdc = GetDC( 0 );
const struct wgl_funcs *wgl_driver = __wine_get_wgl_driver( hdc, WINE_GDI_DRIVER_VERSION );
pwglGetProcAddress = wgl_driver->p_wglGetProcAddress;
ReleaseDC( 0, hdc );
}
#define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn);
#endif
if(!pwglGetProcAddress) {
ERR("Unable to load wglGetProcAddress!\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;
......@@ -5407,13 +5410,8 @@ static BOOL InitAdapters(struct wined3d *wined3d)
/* Load glFinish and glFlush from opengl32.dll even if we're not using WIN32 opengl
* otherwise because we have to use winex11.drv's override
*/
#ifdef USE_WIN32_OPENGL
wglFinish = (void*)GetProcAddress(mod_gl, "glFinish");
wglFlush = (void*)GetProcAddress(mod_gl, "glFlush");
#else
wglFinish = (void*)pwglGetProcAddress("wglFinish");
wglFlush = (void*)pwglGetProcAddress("wglFlush");
#endif
glEnableWINE = glEnable;
glDisableWINE = glDisable;
......
......@@ -1369,7 +1369,7 @@ 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;
PROC (WINE_GLAPI *pwglGetProcAddress)(LPCSTR) DECLSPEC_HIDDEN;
BOOL (WINAPI *pwglMakeCurrent)(HDC, HGLRC) DECLSPEC_HIDDEN;
BOOL (WINAPI *pwglShareLists)(HGLRC, HGLRC) DECLSPEC_HIDDEN;
......
......@@ -1521,10 +1521,8 @@ static HDC WINAPI X11DRV_wglGetCurrentReadDCARB(void)
return ret;
}
/**
/***********************************************************************
* glxdrv_wglGetProcAddress
*
* For OpenGL32 wglGetProcAddress.
*/
static PROC glxdrv_wglGetProcAddress(LPCSTR lpszProc)
{
......@@ -1535,8 +1533,6 @@ static PROC glxdrv_wglGetProcAddress(LPCSTR lpszProc)
if (padding < 0)
padding = 0;
if (!has_opengl()) return NULL;
/* Check the table of WGL extensions to see if we need to return a WGL extension
* or a function pointer to a native OpenGL function. */
if(strncmp(lpszProc, "wgl", 3) != 0) {
......@@ -3596,7 +3592,7 @@ static const struct gdi_dc_funcs glxdrv_funcs =
NULL, /* pWidenPath */
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
glxdrv_wglGetProcAddress, /* pwglGetProcAddress */
NULL, /* pwglGetProcAddress */
glxdrv_wine_get_wgl_driver, /* wine_get_wgl_driver */
GDI_PRIORITY_GRAPHICS_DRV + 20 /* priority */
};
......@@ -3609,6 +3605,7 @@ static const struct wgl_funcs glxdrv_wgl_funcs =
glxdrv_wglCreateContextAttribsARB, /* p_wglCreateContextAttribsARB */
glxdrv_wglDeleteContext, /* p_wglDeleteContext */
glxdrv_wglGetCurrentDC, /* p_wglGetCurrentDC */
glxdrv_wglGetProcAddress, /* p_wglGetProcAddress */
glxdrv_wglMakeContextCurrentARB, /* p_wglMakeContextCurrentARB */
glxdrv_wglMakeCurrent, /* p_wglMakeCurrent */
glxdrv_wglShareLists, /* p_wglShareLists */
......
......@@ -203,7 +203,7 @@ struct gdi_dc_funcs
};
/* increment this when you change the DC function table */
#define WINE_GDI_DRIVER_VERSION 37
#define WINE_GDI_DRIVER_VERSION 38
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */
#define GDI_PRIORITY_FONT_DRV 100 /* any font driver */
......@@ -239,6 +239,7 @@ struct wgl_funcs
HGLRC (*p_wglCreateContextAttribsARB)(HDC,HGLRC,const int*);
BOOL (*p_wglDeleteContext)(HGLRC);
HDC (*p_wglGetCurrentDC)(void);
PROC (*p_wglGetProcAddress)(LPCSTR);
BOOL (*p_wglMakeContextCurrentARB)(HDC,HDC,HGLRC);
BOOL (*p_wglMakeCurrent)(HDC,HGLRC);
BOOL (*p_wglShareLists)(HGLRC,HGLRC);
......
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