Alexandre Julliard : opengl32: Move wglCreateContextAttribsARB to the WGL driver.
Alexandre Julliard
julliard at winehq.org
Thu Jun 28 13:55:16 CDT 2012
Module: wine
Branch: master
Commit: 3bcb8057a17fc3386e756706022510784291869d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3bcb8057a17fc3386e756706022510784291869d
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Jun 28 15:07:44 2012 +0200
opengl32: Move wglCreateContextAttribsARB to the WGL driver.
---
dlls/gdi32/opengl.c | 29 -----------------------------
dlls/opengl32/wgl.c | 27 ++++++++++++++++++++-------
dlls/winex11.drv/opengl.c | 28 +++++++++++++++-------------
include/wine/gdi_driver.h | 3 ++-
4 files changed, 37 insertions(+), 50 deletions(-)
diff --git a/dlls/gdi32/opengl.c b/dlls/gdi32/opengl.c
index ba4106b..81a9824 100644
--- a/dlls/gdi32/opengl.c
+++ b/dlls/gdi32/opengl.c
@@ -82,26 +82,6 @@ HGLRC WINAPI wglCreateContext(HDC hdc)
}
/***********************************************************************
- * wglCreateContextAttribsARB
- */
-static HGLRC WINAPI wglCreateContextAttribsARB(HDC hdc, HGLRC hShareContext, const int *attributeList)
-{
- HGLRC ret = 0;
- DC * dc = get_dc_ptr( hdc );
-
- TRACE("(%p)\n",hdc);
-
- if (dc)
- {
- PHYSDEV physdev = GET_DC_PHYSDEV( dc, pwglCreateContextAttribsARB );
- update_dc( dc );
- ret = physdev->funcs->pwglCreateContextAttribsARB( physdev, hShareContext, attributeList );
- release_dc_ptr( dc );
- }
- return ret;
-}
-
-/***********************************************************************
* Internal wglGetProcAddress for retrieving WGL extensions
*/
PROC WINAPI wglGetProcAddress(LPCSTR func)
@@ -122,15 +102,6 @@ PROC WINAPI wglGetProcAddress(LPCSTR func)
ret = physdev->funcs->pwglGetProcAddress(func);
release_dc_ptr( dc );
}
-
- /* At the moment we implement one WGL extension which requires a HDC. When we
- * are looking up this call and when the Extension is available (that is the case
- * when a non-NULL value is returned by wglGetProcAddress), we return the address
- * of a wrapper function which will handle the HDC->PhysDev conversion.
- */
- if(ret && strcmp(func, "wglCreateContextAttribsARB") == 0)
- return (PROC)wglCreateContextAttribsARB;
-
return ret;
}
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c
index 9761bba..ab26f4a 100644
--- a/dlls/opengl32/wgl.c
+++ b/dlls/opengl32/wgl.c
@@ -133,6 +133,14 @@ BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
}
/***********************************************************************
+ * wglCreateContextAttribsARB (wrapper for the extension function returned by the driver)
+ */
+static HGLRC WINAPI wglCreateContextAttribsARB( HDC hdc, HGLRC share, const int *attribs )
+{
+ return wgl_driver->p_wglCreateContextAttribsARB( hdc, share, attribs );
+}
+
+/***********************************************************************
* wglMakeContextCurrentARB (wrapper for the extension function returned by the driver)
*/
static BOOL WINAPI wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, HGLRC hglrc )
@@ -464,6 +472,12 @@ static BOOL is_extension_supported(const char* extension)
return FALSE;
}
+static const OpenGL_extension wgl_extensions[] =
+{
+ { "wglCreateContextAttribsARB", "WGL_ARB_create_context", wglCreateContextAttribsARB },
+ { "wglMakeContextCurrentARB", "WGL_ARB_make_current_read", wglMakeContextCurrentARB },
+};
+
/***********************************************************************
* wglGetProcAddress (OPENGL32.@)
*/
@@ -499,13 +513,12 @@ PROC WINAPI wglGetProcAddress(LPCSTR lpszProc) {
local_func = wine_wgl.p_wglGetProcAddress( lpszProc );
if (local_func == (void *)1) /* special function that needs a wrapper */
{
- if (!strcmp( lpszProc, "wglMakeContextCurrentARB" ))
- local_func = wglMakeContextCurrentARB;
- else
- {
- FIXME( "wrapper missing for %s\n", lpszProc );
- local_func = NULL;
- }
+ ext_ret = bsearch( &ext, wgl_extensions, sizeof(wgl_extensions)/sizeof(wgl_extensions[0]),
+ sizeof(OpenGL_extension), compar );
+ if (ext_ret) return ext_ret->func;
+
+ FIXME( "wrapper missing for %s\n", lpszProc );
+ return NULL;
}
return local_func;
}
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index f99e98c..90d4cd6 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -1913,35 +1913,36 @@ static void WINAPI X11DRV_wglFlush(void)
}
}
-/**
- * glxdrv_wglCreateContextAttribsARB
- *
- * WGL_ARB_create_context: wglCreateContextAttribsARB
+/***********************************************************************
+ * glxdrv_wglCreateContextAttribsARB
*/
-static HGLRC glxdrv_wglCreateContextAttribsARB(PHYSDEV dev, HGLRC hShareContext, const int* attribList)
+static HGLRC glxdrv_wglCreateContextAttribsARB( HDC hdc, HGLRC hShareContext, const int* attribList )
{
- struct glx_physdev *physdev = get_glxdrv_dev( dev );
+ struct x11drv_escape_get_drawable escape;
Wine_GLContext *ret;
WineGLPixelFormat *fmt;
int fmt_count = 0;
- TRACE("(%p %p %p)\n", dev->hdc, hShareContext, attribList);
+ TRACE("(%p %p %p)\n", hdc, hShareContext, attribList);
- if (!has_opengl()) return 0;
+ escape.code = X11DRV_GET_DRAWABLE;
+ if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape.code), (LPCSTR)&escape.code,
+ sizeof(escape), (LPSTR)&escape ))
+ return 0;
- fmt = ConvertPixelFormatWGLtoGLX(gdi_display, physdev->pixel_format, TRUE /* Offscreen */, &fmt_count);
+ fmt = ConvertPixelFormatWGLtoGLX(gdi_display, escape.pixel_format, TRUE /* Offscreen */, &fmt_count);
/* wglCreateContextAttribsARB supports ALL pixel formats, so also offscreen ones.
* If this fails something is very wrong on the system. */
if(!fmt)
{
- ERR("Cannot get FB Config for iPixelFormat %d, expect problems!\n", physdev->pixel_format);
+ ERR("Cannot get FB Config for iPixelFormat %d, expect problems!\n", escape.pixel_format);
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return NULL;
}
if (!(ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret)))) return 0;
- ret->hdc = dev->hdc;
+ ret->hdc = hdc;
ret->fmt = fmt;
ret->vis = NULL; /* glXCreateContextAttribsARB requires a fbconfig instead of a visual */
ret->gl3_context = TRUE;
@@ -3076,7 +3077,7 @@ static const WineGLExtension WGL_ARB_create_context =
{
"WGL_ARB_create_context",
{
- { "wglCreateContextAttribsARB", (void *)1 /* not called directly */ },
+ { "wglCreateContextAttribsARB", (void *)1 /* called through the glxdrv_wgl_funcs driver */ },
}
};
@@ -3591,7 +3592,7 @@ static const struct gdi_dc_funcs glxdrv_funcs =
NULL, /* pUnrealizePalette */
NULL, /* pWidenPath */
glxdrv_wglCreateContext, /* pwglCreateContext */
- glxdrv_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */
+ NULL, /* pwglCreateContextAttribsARB */
glxdrv_wglGetProcAddress, /* pwglGetProcAddress */
glxdrv_wine_get_wgl_driver, /* wine_get_wgl_driver */
GDI_PRIORITY_GRAPHICS_DRV + 20 /* priority */
@@ -3600,6 +3601,7 @@ static const struct gdi_dc_funcs glxdrv_funcs =
static const struct wgl_funcs glxdrv_wgl_funcs =
{
glxdrv_wglCopyContext, /* p_wglCopyContext */
+ glxdrv_wglCreateContextAttribsARB, /* p_wglCreateContextAttribsARB */
glxdrv_wglDeleteContext, /* p_wglDeleteContext */
glxdrv_wglGetCurrentDC, /* p_wglGetCurrentDC */
glxdrv_wglMakeContextCurrentARB, /* p_wglMakeContextCurrentARB */
diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h
index 4f4ad94..b3d01d4 100644
--- a/include/wine/gdi_driver.h
+++ b/include/wine/gdi_driver.h
@@ -203,7 +203,7 @@ struct gdi_dc_funcs
};
/* increment this when you change the DC function table */
-#define WINE_GDI_DRIVER_VERSION 34
+#define WINE_GDI_DRIVER_VERSION 35
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */
#define GDI_PRIORITY_FONT_DRV 100 /* any font driver */
@@ -234,6 +234,7 @@ static inline void push_dc_driver( PHYSDEV *dev, PHYSDEV physdev, const struct g
struct wgl_funcs
{
BOOL (*p_wglCopyContext)(HGLRC,HGLRC,UINT);
+ HGLRC (*p_wglCreateContextAttribsARB)(HDC,HGLRC,const int*);
BOOL (*p_wglDeleteContext)(HGLRC);
HDC (*p_wglGetCurrentDC)(void);
BOOL (*p_wglMakeContextCurrentARB)(HDC,HDC,HGLRC);
More information about the wine-cvs
mailing list