Commit 7a031d9b authored by Alexandre Julliard's avatar Alexandre Julliard

opengl32: Add the concept of a WGL driver.

parent db25d402
......@@ -529,8 +529,6 @@ const struct gdi_dc_funcs dib_driver =
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
NULL, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
NULL, /* wine_get_wgl_driver */
GDI_PRIORITY_DIB_DRV /* priority */
};
......@@ -685,19 +685,9 @@ static PROC nulldrv_wglGetProcAddress( LPCSTR name )
return NULL;
}
static BOOL nulldrv_wglMakeCurrent( PHYSDEV dev, HGLRC ctx )
static const struct wgl_funcs *nulldrv_wine_get_wgl_driver( PHYSDEV dev, UINT version )
{
return FALSE;
}
static BOOL nulldrv_wglMakeContextCurrentARB( PHYSDEV dev_draw, PHYSDEV dev_read, HGLRC ctx )
{
return FALSE;
}
static BOOL nulldrv_wglSetPixelFormatWINE( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
{
return FALSE;
return NULL;
}
const struct gdi_dc_funcs null_driver =
......@@ -836,9 +826,7 @@ const struct gdi_dc_funcs null_driver =
nulldrv_wglCreateContext, /* pwglCreateContext */
nulldrv_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */
nulldrv_wglGetProcAddress, /* pwglGetProcAddress */
nulldrv_wglMakeContextCurrentARB, /* pwglMakeContextCurrentARB */
nulldrv_wglMakeCurrent, /* pwglMakeCurrent */
nulldrv_wglSetPixelFormatWINE, /* pwglSetPixelFormatWINE */
nulldrv_wine_get_wgl_driver, /* wine_get_wgl_driver */
GDI_PRIORITY_NULL_DRV /* priority */
};
......
......@@ -170,9 +170,7 @@ static const struct gdi_dc_funcs EMFDRV_Funcs =
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
NULL, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
NULL, /* wine_get_wgl_driver */
GDI_PRIORITY_GRAPHICS_DRV /* priority */
};
......
......@@ -7874,9 +7874,7 @@ static const struct gdi_dc_funcs freetype_funcs =
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
NULL, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
NULL, /* wine_get_wgl_driver */
GDI_PRIORITY_FONT_DRV /* priority */
};
......
......@@ -518,3 +518,6 @@
# GDI objects
@ cdecl __wine_make_gdi_object_system(long long)
@ cdecl __wine_set_visible_region(long long ptr)
# OpenGL
@ cdecl __wine_get_wgl_driver(long long)
......@@ -233,9 +233,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
NULL, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
NULL, /* wine_get_wgl_driver */
GDI_PRIORITY_GRAPHICS_DRV /* priority */
};
......
......@@ -134,6 +134,23 @@ PROC WINAPI wglGetProcAddress(LPCSTR func)
return ret;
}
/***********************************************************************
* __wine_get_wgl_driver (GDI32.@)
*/
const struct wgl_funcs * CDECL __wine_get_wgl_driver( HDC hdc, UINT version )
{
const struct wgl_funcs *ret = NULL;
DC * dc = get_dc_ptr( hdc );
if (dc)
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, wine_get_wgl_driver );
ret = physdev->funcs->wine_get_wgl_driver( physdev, version );
release_dc_ptr( dc );
}
return ret;
}
/******************************************************************************
* ChoosePixelFormat (GDI32.@)
*/
......
......@@ -2367,8 +2367,6 @@ const struct gdi_dc_funcs path_driver =
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
NULL, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
NULL, /* wine_get_wgl_driver */
GDI_PRIORITY_PATH_DRV /* priority */
};
......@@ -39,6 +39,7 @@
#undef near
#include <GL/glu.h>
#endif
#include "wine/gdi_driver.h"
#include "wine/library.h"
#include "wine/debug.h"
......@@ -52,17 +53,14 @@ static struct
INT (WINAPI *p_GetPixelFormat)(HDC hdc);
/* internal WGL functions */
BOOL (WINAPI *p_wglCopyContext)(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask);
BOOL (WINAPI *p_wglDeleteContext)(HGLRC hglrc);
void (WINAPI *p_wglFinish)(void);
void (WINAPI *p_wglFlush)(void);
HGLRC (WINAPI *p_wglGetCurrentContext)(void);
HDC (WINAPI *p_wglGetCurrentDC)(void);
void (WINAPI *p_wglGetIntegerv)(GLenum pname, GLint* params);
BOOL (WINAPI *p_wglMakeCurrent)(HDC hdc, HGLRC hglrc);
BOOL (WINAPI *p_wglShareLists)(HGLRC hglrc1, HGLRC hglrc2);
} wine_wgl;
static const struct wgl_funcs *wgl_driver;
#ifdef SONAME_LIBGLU
#define MAKE_FUNCPTR(f) static typeof(f) * p##f;
MAKE_FUNCPTR(gluNewTess)
......@@ -105,7 +103,7 @@ BOOL WINAPI wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
return wine_wgl.p_wglCopyContext(hglrcSrc, hglrcDst, mask);
return wgl_driver->p_wglCopyContext(hglrcSrc, hglrcDst, mask);
}
/***********************************************************************
......@@ -118,7 +116,7 @@ BOOL WINAPI wglDeleteContext(HGLRC hglrc)
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
return wine_wgl.p_wglDeleteContext(hglrc);
return wgl_driver->p_wglDeleteContext(hglrc);
}
/***********************************************************************
......@@ -131,7 +129,7 @@ BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
SetLastError( ERROR_INVALID_HANDLE );
return FALSE;
}
return wine_wgl.p_wglMakeCurrent(hdc, hglrc);
return wgl_driver->p_wglMakeCurrent(hdc, hglrc);
}
/***********************************************************************
......@@ -144,7 +142,7 @@ BOOL WINAPI wglShareLists(HGLRC hglrc1, HGLRC hglrc2)
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
return wine_wgl.p_wglShareLists(hglrc1, hglrc2);
return wgl_driver->p_wglShareLists(hglrc1, hglrc2);
}
/***********************************************************************
......@@ -152,7 +150,7 @@ BOOL WINAPI wglShareLists(HGLRC hglrc1, HGLRC hglrc2)
*/
HDC WINAPI wglGetCurrentDC(void)
{
return wine_wgl.p_wglGetCurrentDC();
return wgl_driver->p_wglGetCurrentDC();
}
/***********************************************************************
......@@ -1084,8 +1082,11 @@ BOOL WINAPI DECLSPEC_HOTPATCH wglSwapBuffers( HDC hdc )
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 );
GetDesktopWindow(); /* make sure winex11 is loaded (FIXME) */
mod_gdi32 = GetModuleHandleA( "gdi32.dll" );
if (!mod_gdi32)
......@@ -1099,15 +1100,10 @@ static BOOL process_attach(void)
wine_wgl.p_GetPixelFormat = (void *)GetProcAddress(mod_gdi32, "GetPixelFormat");
/* internal WGL functions */
wine_wgl.p_wglCopyContext = (void *)wine_wgl.p_wglGetProcAddress("wglCopyContext");
wine_wgl.p_wglDeleteContext = (void *)wine_wgl.p_wglGetProcAddress("wglDeleteContext");
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_wglGetCurrentDC = (void *)wine_wgl.p_wglGetProcAddress("wglGetCurrentDC");
wine_wgl.p_wglGetIntegerv = (void *)wine_wgl.p_wglGetProcAddress("wglGetIntegerv");
wine_wgl.p_wglMakeCurrent = (void *)wine_wgl.p_wglGetProcAddress("wglMakeCurrent");
wine_wgl.p_wglShareLists = (void *)wine_wgl.p_wglGetProcAddress("wglShareLists");
return TRUE;
}
......
......@@ -844,9 +844,7 @@ static const struct gdi_dc_funcs psdrv_funcs =
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
NULL, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
NULL, /* wine_get_wgl_driver */
GDI_PRIORITY_GRAPHICS_DRV /* priority */
};
......
......@@ -500,15 +500,6 @@ static PROC X11DRV_wglGetProcAddress( LPCSTR proc )
return NULL;
}
/***********************************************************************
* X11DRV_wglSetPixelFormatWINE
*/
static BOOL X11DRV_wglSetPixelFormatWINE( PHYSDEV dev, int fmt, const PIXELFORMATDESCRIPTOR *ppfd )
{
opengl_error();
return FALSE;
}
static const struct gdi_dc_funcs x11drv_funcs =
{
......@@ -646,9 +637,7 @@ static const struct gdi_dc_funcs x11drv_funcs =
X11DRV_wglCreateContext, /* pwglCreateContext */
X11DRV_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */
X11DRV_wglGetProcAddress, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
X11DRV_wglSetPixelFormatWINE, /* pwglSetPixelFormatWINE */
NULL, /* wine_get_wgl_driver */
GDI_PRIORITY_GRAPHICS_DRV /* priority */
};
......
......@@ -6,6 +6,7 @@
* Copyright 2005 Raphael Junqueira
* Copyright 2006-2009 Roderick Colenbrander
* Copyright 2006 Tomas Carnecky
* Copyright 2012 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -158,6 +159,7 @@ struct glx_physdev
Pixmap pixmap; /* pixmap for a DL_GL_PIXMAP_WIN drawable */
};
static const struct wgl_funcs glxdrv_wgl_funcs;
static const struct gdi_dc_funcs glxdrv_funcs;
static inline struct glx_physdev *get_glxdrv_dev( PHYSDEV dev )
......@@ -1393,12 +1395,10 @@ static BOOL glxdrv_SetPixelFormat(PHYSDEV dev, int iPixelFormat, const PIXELFORM
return TRUE;
}
/**
* X11DRV_wglCopyContext
*
* For OpenGL32 wglCopyContext.
/***********************************************************************
* glxdrv_wglCopyContext
*/
static BOOL WINAPI X11DRV_wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
static BOOL glxdrv_wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
{
Wine_GLContext *src = (Wine_GLContext*)hglrcSrc;
Wine_GLContext *dst = (Wine_GLContext*)hglrcDst;
......@@ -1457,14 +1457,10 @@ static HGLRC glxdrv_wglCreateContext(PHYSDEV dev)
return (HGLRC) ret;
}
static BOOL WINAPI X11DRV_wglMakeCurrent(HDC hdc, HGLRC hglrc);
/**
* X11DRV_wglDeleteContext
*
* For OpenGL32 wglDeleteContext.
/***********************************************************************
* glxdrv_wglDeleteContext
*/
static BOOL WINAPI X11DRV_wglDeleteContext(HGLRC hglrc)
static BOOL glxdrv_wglDeleteContext(HGLRC hglrc)
{
Wine_GLContext *ctx = (Wine_GLContext *) hglrc;
......@@ -1487,7 +1483,12 @@ static BOOL WINAPI X11DRV_wglDeleteContext(HGLRC hglrc)
/* WGL makes a context not current if it is active before deletion. GLX waits until the context is not current. */
if (ctx == NtCurrentTeb()->glContext)
X11DRV_wglMakeCurrent(ctx->hdc, NULL);
{
wine_tsx11_lock();
pglXMakeCurrent(gdi_display, None, NULL);
wine_tsx11_unlock();
NtCurrentTeb()->glContext = NULL;
}
wine_tsx11_lock();
list_remove( &ctx->entry );
......@@ -1573,12 +1574,10 @@ static GLXPixmap get_context_pixmap( HDC hdc, struct wine_glcontext *ctx )
return ctx->glxpixmap;
}
/**
* X11DRV_wglMakeCurrent
*
* For OpenGL32 wglMakeCurrent.
/***********************************************************************
* glxdrv_wglMakeCurrent
*/
static BOOL WINAPI X11DRV_wglMakeCurrent(HDC hdc, HGLRC hglrc)
static BOOL glxdrv_wglMakeCurrent(HDC hdc, HGLRC hglrc)
{
BOOL ret;
Wine_GLContext *prev_ctx = NtCurrentTeb()->glContext;
......@@ -1726,20 +1725,16 @@ static BOOL WINAPI X11DRV_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc,
return ret;
}
/**
* X11DRV_wglShareLists
*
* For OpenGL32 wglShareLists.
/***********************************************************************
* glxdrv_wglShareLists
*/
static BOOL WINAPI X11DRV_wglShareLists(HGLRC hglrc1, HGLRC hglrc2)
static BOOL glxdrv_wglShareLists(HGLRC hglrc1, HGLRC hglrc2)
{
Wine_GLContext *org = (Wine_GLContext *) hglrc1;
Wine_GLContext *dest = (Wine_GLContext *) hglrc2;
TRACE("(%p, %p)\n", org, dest);
if (!has_opengl()) return FALSE;
/* Sharing of display lists works differently in GLX and WGL. In case of GLX it is done
* at context creation time but in case of WGL it is done using wglShareLists.
* In the past we tried to emulate wglShareLists by delaying GLX context creation until
......@@ -1795,9 +1790,9 @@ static HGLRC WINAPI X11DRV_wglGetCurrentContext(void)
}
/***********************************************************************
* X11DRV_wglGetCurrentDC
* glxdrv_wglGetCurrentDC
*/
static HDC WINAPI X11DRV_wglGetCurrentDC(void)
static HDC glxdrv_wglGetCurrentDC(void)
{
Wine_GLContext *ctx = NtCurrentTeb()->glContext;
......@@ -3071,15 +3066,10 @@ static const WineGLExtension WGL_internal_functions =
{
"",
{
{ "wglCopyContext", X11DRV_wglCopyContext },
{ "wglDeleteContext", X11DRV_wglDeleteContext },
{ "wglFinish", X11DRV_wglFinish },
{ "wglFlush", X11DRV_wglFlush },
{ "wglGetCurrentContext", X11DRV_wglGetCurrentContext },
{ "wglGetCurrentDC", X11DRV_wglGetCurrentDC },
{ "wglGetIntegerv", X11DRV_wglGetIntegerv },
{ "wglMakeCurrent", X11DRV_wglMakeCurrent },
{ "wglShareLists", X11DRV_wglShareLists },
}
};
......@@ -3285,8 +3275,6 @@ static BOOL glxdrv_SwapBuffers(PHYSDEV dev)
struct glx_physdev *physdev = get_glxdrv_dev( dev );
Wine_GLContext *ctx = NtCurrentTeb()->glContext;
if (!has_opengl()) return FALSE;
TRACE("(%p)\n", dev->hdc);
if (!ctx)
......@@ -3457,6 +3445,20 @@ static INT glxdrv_ExtEscape( PHYSDEV dev, INT escape, INT in_count, LPCVOID in_d
return dev->funcs->pExtEscape( dev, escape, in_count, in_data, out_count, out_data );
}
/**********************************************************************
* glxdrv_wine_get_wgl_driver
*/
static const struct wgl_funcs * glxdrv_wine_get_wgl_driver( PHYSDEV dev, UINT version )
{
if (version != WINE_GDI_DRIVER_VERSION)
{
ERR( "version mismatch, opengl32 wants %u but driver has %u\n", version, WINE_GDI_DRIVER_VERSION );
return NULL;
}
if (!has_opengl()) return NULL;
return &glxdrv_wgl_funcs;
}
static const struct gdi_dc_funcs glxdrv_funcs =
{
NULL, /* pAbortDoc */
......@@ -3593,12 +3595,19 @@ static const struct gdi_dc_funcs glxdrv_funcs =
glxdrv_wglCreateContext, /* pwglCreateContext */
glxdrv_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */
glxdrv_wglGetProcAddress, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
glxdrv_wine_get_wgl_driver, /* wine_get_wgl_driver */
GDI_PRIORITY_GRAPHICS_DRV + 20 /* priority */
};
static const struct wgl_funcs glxdrv_wgl_funcs =
{
glxdrv_wglCopyContext, /* p_wglCopyContext */
glxdrv_wglDeleteContext, /* p_wglDeleteContext */
glxdrv_wglGetCurrentDC, /* p_wglGetCurrentDC */
glxdrv_wglMakeCurrent, /* p_wglMakeCurrent */
glxdrv_wglShareLists, /* p_wglShareLists */
};
const struct gdi_dc_funcs *get_glx_driver(void)
{
return &glxdrv_funcs;
......
......@@ -2600,9 +2600,7 @@ static const struct gdi_dc_funcs xrender_funcs =
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
NULL, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
NULL, /* wine_get_wgl_driver */
GDI_PRIORITY_GRAPHICS_DRV + 10 /* priority */
};
......
......@@ -22,6 +22,7 @@
#define __WINE_WINE_GDI_DRIVER_H
struct gdi_dc_funcs;
struct wgl_funcs;
typedef struct gdi_physdev
{
......@@ -195,16 +196,14 @@ struct gdi_dc_funcs
HGLRC (*pwglCreateContext)(PHYSDEV);
HGLRC (*pwglCreateContextAttribsARB)(PHYSDEV,HGLRC,const int*);
PROC (*pwglGetProcAddress)(LPCSTR);
BOOL (*pwglMakeContextCurrentARB)(PHYSDEV,PHYSDEV,HGLRC);
BOOL (*pwglMakeCurrent)(PHYSDEV,HGLRC);
BOOL (*pwglSetPixelFormatWINE)(PHYSDEV,INT,const PIXELFORMATDESCRIPTOR*);
const struct wgl_funcs * (*wine_get_wgl_driver)(PHYSDEV,UINT);
/* priority order for the driver on the stack */
UINT priority;
};
/* increment this when you change the DC function table */
#define WINE_GDI_DRIVER_VERSION 32
#define WINE_GDI_DRIVER_VERSION 33
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */
#define GDI_PRIORITY_FONT_DRV 100 /* any font driver */
......@@ -230,6 +229,17 @@ static inline void push_dc_driver( PHYSDEV *dev, PHYSDEV physdev, const struct g
*dev = physdev;
}
/* OpenGL support */
struct wgl_funcs
{
BOOL (*p_wglCopyContext)(HGLRC,HGLRC,UINT);
BOOL (*p_wglDeleteContext)(HGLRC);
HDC (*p_wglGetCurrentDC)(void);
BOOL (*p_wglMakeCurrent)(HDC,HGLRC);
BOOL (*p_wglShareLists)(HGLRC,HGLRC);
};
/* the DC hook support is only exported on Win16, the 32-bit version is a Wine extension */
#define DCHC_INVALIDVISRGN 0x0001
......@@ -245,5 +255,6 @@ WINGDIAPI WORD WINAPI SetHookFlags(HDC,WORD);
extern void CDECL __wine_make_gdi_object_system( HGDIOBJ handle, BOOL set );
extern void CDECL __wine_set_visible_region( HDC hdc, HRGN hrgn, const RECT *vis_rect );
extern const struct wgl_funcs * CDECL __wine_get_wgl_driver( HDC hdc, UINT version );
#endif /* __WINE_WINE_GDI_DRIVER_H */
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