Commit 8a13afed authored by Alexandre Julliard's avatar Alexandre Julliard

opengl32: Move GetPixelFormat to the WGL driver.

parent bbdf77a3
......@@ -42,6 +42,7 @@ static const WCHAR opengl32W[] = {'o','p','e','n','g','l','3','2','.','d','l','l
static HMODULE opengl32;
static INT (WINAPI *wglChoosePixelFormat)(HDC,const PIXELFORMATDESCRIPTOR *);
static INT (WINAPI *wglDescribePixelFormat)(HDC,INT,UINT,PIXELFORMATDESCRIPTOR*);
static INT (WINAPI *wglGetPixelFormat)(HDC);
static BOOL (WINAPI *wglSetPixelFormat)(HDC,INT,const PIXELFORMATDESCRIPTOR*);
static BOOL (WINAPI *wglSwapBuffers)(HDC);
......@@ -131,6 +132,20 @@ INT WINAPI DescribePixelFormat( HDC hdc, INT fmt, UINT size, PIXELFORMATDESCRIPT
}
/******************************************************************************
* GetPixelFormat (GDI32.@)
*/
INT WINAPI GetPixelFormat( HDC hdc )
{
if (!wglGetPixelFormat)
{
if (!opengl32) opengl32 = LoadLibraryW( opengl32W );
if (!(wglGetPixelFormat = (void *)GetProcAddress( opengl32, "wglGetPixelFormat" )))
return 0;
}
return wglGetPixelFormat( hdc );
}
/******************************************************************************
* SetPixelFormat (GDI32.@)
*/
BOOL WINAPI SetPixelFormat( HDC hdc, INT fmt, const PIXELFORMATDESCRIPTOR *pfd )
......
......@@ -509,35 +509,6 @@ BOOL WINAPI GdiSetPixelFormat( HDC hdc, INT iPixelFormat, const PIXELFORMATDESCR
/******************************************************************************
* GetPixelFormat [GDI32.@]
* Gets index of pixel format of DC
*
* PARAMETERS
* hdc [I] Device context whose pixel format index is sought
*
* RETURNS
* Success: Currently selected pixel format
* Failure: 0
*/
INT WINAPI GetPixelFormat( HDC hdc )
{
INT ret = 0;
DC * dc = get_dc_ptr( hdc );
TRACE("(%p)\n",hdc);
if (dc)
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGetPixelFormat );
update_dc( dc );
ret = physdev->funcs->pGetPixelFormat( physdev );
release_dc_ptr( dc );
}
return ret;
}
/******************************************************************************
* GdiDescribePixelFormat [GDI32.@]
*
* Probably not the correct semantics, it's supposed to be an internal backend for DescribePixelFormat.
......
......@@ -49,7 +49,6 @@ WINE_DECLARE_DEBUG_CHANNEL(opengl);
static struct
{
PROC (WINAPI *p_wglGetProcAddress)(LPCSTR lpszProc);
INT (WINAPI *p_GetPixelFormat)(HDC hdc);
/* internal WGL functions */
void (WINAPI *p_wglFinish)(void);
......@@ -361,7 +360,7 @@ INT WINAPI wglDescribePixelFormat(HDC hdc, INT iPixelFormat, UINT nBytes,
*/
INT WINAPI wglGetPixelFormat(HDC hdc)
{
return wine_wgl.p_GetPixelFormat(hdc);
return wgl_driver->p_GetPixelFormat( hdc );
}
/***********************************************************************
......@@ -1129,7 +1128,6 @@ static BOOL process_attach(void)
}
wine_wgl.p_wglGetProcAddress = (void *)GetProcAddress(mod_gdi32, "wglGetProcAddress");
wine_wgl.p_GetPixelFormat = (void *)GetProcAddress(mod_gdi32, "GetPixelFormat");
/* internal WGL functions */
wine_wgl.p_wglFinish = (void *)wine_wgl.p_wglGetProcAddress("wglFinish");
......
......@@ -1281,41 +1281,43 @@ static int glxdrv_DescribePixelFormat(PHYSDEV dev, int iPixelFormat,
return ret;
}
/**
* glxdrv_GetPixelFormat
*
* Get the pixel-format id used by this DC
/***********************************************************************
* glxdrv_GetPixelFormat
*/
static int glxdrv_GetPixelFormat(PHYSDEV dev)
static int glxdrv_GetPixelFormat( HDC hdc )
{
struct glx_physdev *physdev = get_glxdrv_dev( dev );
WineGLPixelFormat *fmt;
int tmp;
struct x11drv_escape_get_drawable escape;
WineGLPixelFormat *fmt;
int tmp;
if (!physdev->pixel_format) return 0; /* not set yet */
TRACE( "(%p)\n", hdc );
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, physdev->pixel_format, TRUE, &tmp);
if(!fmt)
{
ERR("Unable to find a WineGLPixelFormat for iPixelFormat=%d\n", physdev->pixel_format);
return 0;
}
else if(fmt->offscreenOnly)
{
/* Offscreen formats can't be used with traditional WGL calls.
* As has been verified on Windows GetPixelFormat doesn't fail but returns iPixelFormat=1. */
TRACE("Returning iPixelFormat=1 for offscreen format: %d\n", fmt->iPixelFormat);
return 1;
}
escape.code = X11DRV_GET_DRAWABLE;
if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape.code), (LPCSTR)&escape.code,
sizeof(escape), (LPSTR)&escape ))
return 0;
TRACE("(%p): returns %d\n", dev->hdc, physdev->pixel_format);
return physdev->pixel_format;
if (!escape.pixel_format) return 0; /* not set yet */
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, escape.pixel_format, TRUE, &tmp);
if (!fmt)
{
ERR("Unable to find a WineGLPixelFormat for iPixelFormat=%d\n", escape.pixel_format);
return 0;
}
if (fmt->offscreenOnly)
{
/* Offscreen formats can't be used with traditional WGL calls.
* As has been verified on Windows GetPixelFormat doesn't fail but returns iPixelFormat=1. */
TRACE("Returning iPixelFormat=1 for offscreen format: %d\n", fmt->iPixelFormat);
return 1;
}
TRACE("(%p): returns %d\n", hdc, escape.pixel_format);
return escape.pixel_format;
}
/**
* glxdrv_SetPixelFormat
*
* Set the pixel-format id used by this DC
/***********************************************************************
* glxdrv_SetPixelFormat
*/
static BOOL glxdrv_SetPixelFormat(PHYSDEV dev, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd)
{
......@@ -3513,7 +3515,7 @@ static const struct gdi_dc_funcs glxdrv_funcs =
NULL, /* pGetNearestColor */
NULL, /* pGetOutlineTextMetrics */
NULL, /* pGetPixel */
glxdrv_GetPixelFormat, /* pGetPixelFormat */
NULL, /* pGetPixelFormat */
NULL, /* pGetSystemPaletteEntries */
NULL, /* pGetTextCharsetInfo */
NULL, /* pGetTextExtentExPoint */
......@@ -3601,6 +3603,7 @@ static const struct gdi_dc_funcs glxdrv_funcs =
static const struct wgl_funcs glxdrv_wgl_funcs =
{
glxdrv_GetPixelFormat, /* p_GetPixelFormat */
glxdrv_wglCopyContext, /* p_wglCopyContext */
glxdrv_wglCreateContext, /* p_wglCreateContext */
glxdrv_wglCreateContextAttribsARB, /* p_wglCreateContextAttribsARB */
......
......@@ -203,7 +203,7 @@ struct gdi_dc_funcs
};
/* increment this when you change the DC function table */
#define WINE_GDI_DRIVER_VERSION 36
#define WINE_GDI_DRIVER_VERSION 37
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */
#define GDI_PRIORITY_FONT_DRV 100 /* any font driver */
......@@ -233,6 +233,7 @@ static inline void push_dc_driver( PHYSDEV *dev, PHYSDEV physdev, const struct g
struct wgl_funcs
{
INT (*p_GetPixelFormat)(HDC);
BOOL (*p_wglCopyContext)(HGLRC,HGLRC,UINT);
HGLRC (*p_wglCreateContext)(HDC);
HGLRC (*p_wglCreateContextAttribsARB)(HDC,HGLRC,const int*);
......
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