winex11: Move ChoosePixelFormat implementation to opengl32 and base it on DescribePixelFormat.
This commit is contained in:
parent
9ceb1fc188
commit
81cd178ae1
|
@ -38,6 +38,10 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(wgl);
|
WINE_DEFAULT_DEBUG_CHANNEL(wgl);
|
||||||
|
|
||||||
|
static const WCHAR opengl32W[] = {'o','p','e','n','g','l','3','2','.','d','l','l',0};
|
||||||
|
static HMODULE opengl32;
|
||||||
|
static INT (WINAPI *wglChoosePixelFormat)(HDC,const PIXELFORMATDESCRIPTOR *);
|
||||||
|
|
||||||
static HDC default_hdc = 0;
|
static HDC default_hdc = 0;
|
||||||
|
|
||||||
/* We route all wgl functions from opengl32.dll through gdi32.dll to
|
/* We route all wgl functions from opengl32.dll through gdi32.dll to
|
||||||
|
@ -219,3 +223,17 @@ PROC WINAPI wglGetProcAddress(LPCSTR func)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* ChoosePixelFormat (GDI32.@)
|
||||||
|
*/
|
||||||
|
INT WINAPI ChoosePixelFormat( HDC hdc, const PIXELFORMATDESCRIPTOR *pfd )
|
||||||
|
{
|
||||||
|
if (!wglChoosePixelFormat)
|
||||||
|
{
|
||||||
|
if (!opengl32) opengl32 = LoadLibraryW( opengl32W );
|
||||||
|
if (!(wglChoosePixelFormat = (void *)GetProcAddress( opengl32, "wglChoosePixelFormat" )))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return wglChoosePixelFormat( hdc, pfd );
|
||||||
|
}
|
||||||
|
|
|
@ -485,35 +485,6 @@ COLORREF WINAPI GetPixel( HDC hdc, INT x, INT y )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* ChoosePixelFormat [GDI32.@]
|
|
||||||
* Matches a pixel format to given format
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* hdc [I] Device context to search for best pixel match
|
|
||||||
* ppfd [I] Pixel format for which a match is sought
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: Pixel format index closest to given format
|
|
||||||
* Failure: 0
|
|
||||||
*/
|
|
||||||
INT WINAPI ChoosePixelFormat( HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd )
|
|
||||||
{
|
|
||||||
INT ret = 0;
|
|
||||||
DC * dc = get_dc_ptr( hdc );
|
|
||||||
|
|
||||||
TRACE("(%p,%p)\n",hdc,ppfd);
|
|
||||||
|
|
||||||
if (dc)
|
|
||||||
{
|
|
||||||
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pChoosePixelFormat );
|
|
||||||
ret = physdev->funcs->pChoosePixelFormat( physdev, ppfd );
|
|
||||||
release_dc_ptr( dc );
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* SetPixelFormat [GDI32.@]
|
* SetPixelFormat [GDI32.@]
|
||||||
* Sets pixel format of device context
|
* Sets pixel format of device context
|
||||||
|
|
|
@ -51,7 +51,6 @@ static struct
|
||||||
BOOL (WINAPI *p_SetPixelFormat)(HDC hdc, INT iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd);
|
BOOL (WINAPI *p_SetPixelFormat)(HDC hdc, INT iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd);
|
||||||
BOOL (WINAPI *p_wglMakeCurrent)(HDC hdc, HGLRC hglrc);
|
BOOL (WINAPI *p_wglMakeCurrent)(HDC hdc, HGLRC hglrc);
|
||||||
HGLRC (WINAPI *p_wglCreateContext)(HDC hdc);
|
HGLRC (WINAPI *p_wglCreateContext)(HDC hdc);
|
||||||
INT (WINAPI *p_ChoosePixelFormat)(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd);
|
|
||||||
INT (WINAPI *p_DescribePixelFormat)(HDC hdc, INT iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd);
|
INT (WINAPI *p_DescribePixelFormat)(HDC hdc, INT iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd);
|
||||||
INT (WINAPI *p_GetPixelFormat)(HDC hdc);
|
INT (WINAPI *p_GetPixelFormat)(HDC hdc);
|
||||||
|
|
||||||
|
@ -175,7 +174,162 @@ HGLRC WINAPI wglGetCurrentContext(void)
|
||||||
*/
|
*/
|
||||||
INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd)
|
INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd)
|
||||||
{
|
{
|
||||||
return wine_wgl.p_ChoosePixelFormat(hdc, ppfd);
|
PIXELFORMATDESCRIPTOR format, best;
|
||||||
|
int i, count, best_format;
|
||||||
|
int bestDBuffer = -1, bestStereo = -1;
|
||||||
|
|
||||||
|
TRACE_(wgl)( "%p %p: size %u version %u flags %u type %u color %u %u,%u,%u,%u "
|
||||||
|
"accum %u depth %u stencil %u aux %u\n",
|
||||||
|
hdc, ppfd, ppfd->nSize, ppfd->nVersion, ppfd->dwFlags, ppfd->iPixelType,
|
||||||
|
ppfd->cColorBits, ppfd->cRedBits, ppfd->cGreenBits, ppfd->cBlueBits, ppfd->cAlphaBits,
|
||||||
|
ppfd->cAccumBits, ppfd->cDepthBits, ppfd->cStencilBits, ppfd->cAuxBuffers );
|
||||||
|
|
||||||
|
count = wine_wgl.p_DescribePixelFormat( hdc, 0, 0, NULL );
|
||||||
|
if (!count) return 0;
|
||||||
|
|
||||||
|
best_format = 0;
|
||||||
|
best.dwFlags = 0;
|
||||||
|
best.cAlphaBits = -1;
|
||||||
|
best.cColorBits = -1;
|
||||||
|
best.cDepthBits = -1;
|
||||||
|
best.cStencilBits = -1;
|
||||||
|
best.cAuxBuffers = -1;
|
||||||
|
|
||||||
|
for (i = 1; i <= count; i++)
|
||||||
|
{
|
||||||
|
if (!wine_wgl.p_DescribePixelFormat( hdc, i, sizeof(format), &format )) continue;
|
||||||
|
|
||||||
|
if (ppfd->iPixelType != format.iPixelType)
|
||||||
|
{
|
||||||
|
TRACE( "pixel type mismatch for iPixelFormat=%d\n", i );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* only use bitmap capable for formats for bitmap rendering */
|
||||||
|
if( (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) != (format.dwFlags & PFD_DRAW_TO_BITMAP))
|
||||||
|
{
|
||||||
|
TRACE( "PFD_DRAW_TO_BITMAP mismatch for iPixelFormat=%d\n", i );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The behavior of PDF_STEREO/PFD_STEREO_DONTCARE and PFD_DOUBLEBUFFER / PFD_DOUBLEBUFFER_DONTCARE
|
||||||
|
* is not very clear on MSDN. They specify that ChoosePixelFormat tries to match pixel formats
|
||||||
|
* with the flag (PFD_STEREO / PFD_DOUBLEBUFFERING) set. Otherwise it says that it tries to match
|
||||||
|
* formats without the given flag set.
|
||||||
|
* A test on Windows using a Radeon 9500pro on WinXP (the driver doesn't support Stereo)
|
||||||
|
* has indicated that a format without stereo is returned when stereo is unavailable.
|
||||||
|
* So in case PFD_STEREO is set, formats that support it should have priority above formats
|
||||||
|
* without. In case PFD_STEREO_DONTCARE is set, stereo is ignored.
|
||||||
|
*
|
||||||
|
* To summarize the following is most likely the correct behavior:
|
||||||
|
* stereo not set -> prefer no-stereo formats, else also accept stereo formats
|
||||||
|
* stereo set -> prefer stereo formats, else also accept no-stereo formats
|
||||||
|
* stereo don't care -> it doesn't matter whether we get stereo or not
|
||||||
|
*
|
||||||
|
* In Wine we will treat no-stereo the same way as don't care because it makes
|
||||||
|
* format selection even more complicated and second drivers with Stereo advertise
|
||||||
|
* each format twice anyway.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Doublebuffer, see the comments above */
|
||||||
|
if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE))
|
||||||
|
{
|
||||||
|
if (((ppfd->dwFlags & PFD_DOUBLEBUFFER) != bestDBuffer) &&
|
||||||
|
((format.dwFlags & PFD_DOUBLEBUFFER) == (ppfd->dwFlags & PFD_DOUBLEBUFFER)))
|
||||||
|
goto found;
|
||||||
|
|
||||||
|
if (bestDBuffer != -1 && (format.dwFlags & PFD_DOUBLEBUFFER) != bestDBuffer) continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Stereo, see the comments above. */
|
||||||
|
if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE))
|
||||||
|
{
|
||||||
|
if (((ppfd->dwFlags & PFD_STEREO) != bestStereo) &&
|
||||||
|
((format.dwFlags & PFD_STEREO) == (ppfd->dwFlags & PFD_STEREO)))
|
||||||
|
goto found;
|
||||||
|
|
||||||
|
if (bestStereo != -1 && (format.dwFlags & PFD_STEREO) != bestStereo) continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Below we will do a number of checks to select the 'best' pixelformat.
|
||||||
|
* We assume the precedence cColorBits > cAlphaBits > cDepthBits > cStencilBits -> cAuxBuffers.
|
||||||
|
* The code works by trying to match the most important options as close as possible.
|
||||||
|
* When a reasonable format is found, we will try to match more options.
|
||||||
|
* It appears (see the opengl32 test) that Windows opengl drivers ignore options
|
||||||
|
* like cColorBits, cAlphaBits and friends if they are set to 0, so they are considered
|
||||||
|
* as DONTCARE. At least Serious Sam TSE relies on this behavior. */
|
||||||
|
|
||||||
|
if (ppfd->cColorBits)
|
||||||
|
{
|
||||||
|
if (((ppfd->cColorBits > best.cColorBits) && (format.cColorBits > best.cColorBits)) ||
|
||||||
|
((format.cColorBits >= ppfd->cColorBits) && (format.cColorBits < best.cColorBits)))
|
||||||
|
goto found;
|
||||||
|
|
||||||
|
if (best.cColorBits != format.cColorBits) /* Do further checks if the format is compatible */
|
||||||
|
{
|
||||||
|
TRACE( "color mismatch for iPixelFormat=%d\n", i );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ppfd->cAlphaBits)
|
||||||
|
{
|
||||||
|
if (((ppfd->cAlphaBits > best.cAlphaBits) && (format.cAlphaBits > best.cAlphaBits)) ||
|
||||||
|
((format.cAlphaBits >= ppfd->cAlphaBits) && (format.cAlphaBits < best.cAlphaBits)))
|
||||||
|
goto found;
|
||||||
|
|
||||||
|
if (best.cAlphaBits != format.cAlphaBits)
|
||||||
|
{
|
||||||
|
TRACE( "alpha mismatch for iPixelFormat=%d\n", i );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ppfd->cDepthBits)
|
||||||
|
{
|
||||||
|
if (((ppfd->cDepthBits > best.cDepthBits) && (format.cDepthBits > best.cDepthBits)) ||
|
||||||
|
((format.cDepthBits >= ppfd->cDepthBits) && (format.cDepthBits < best.cDepthBits)))
|
||||||
|
goto found;
|
||||||
|
|
||||||
|
if (best.cDepthBits != format.cDepthBits)
|
||||||
|
{
|
||||||
|
TRACE( "depth mismatch for iPixelFormat=%d\n", i );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ppfd->cStencilBits)
|
||||||
|
{
|
||||||
|
if (((ppfd->cStencilBits > best.cStencilBits) && (format.cStencilBits > best.cStencilBits)) ||
|
||||||
|
((format.cStencilBits >= ppfd->cStencilBits) && (format.cStencilBits < best.cStencilBits)))
|
||||||
|
goto found;
|
||||||
|
|
||||||
|
if (best.cStencilBits != format.cStencilBits)
|
||||||
|
{
|
||||||
|
TRACE( "stencil mismatch for iPixelFormat=%d\n", i );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ppfd->cAuxBuffers)
|
||||||
|
{
|
||||||
|
if (((ppfd->cAuxBuffers > best.cAuxBuffers) && (format.cAuxBuffers > best.cAuxBuffers)) ||
|
||||||
|
((format.cAuxBuffers >= ppfd->cAuxBuffers) && (format.cAuxBuffers < best.cAuxBuffers)))
|
||||||
|
goto found;
|
||||||
|
|
||||||
|
if (best.cAuxBuffers != format.cAuxBuffers)
|
||||||
|
{
|
||||||
|
TRACE( "aux mismatch for iPixelFormat=%d\n", i );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
|
||||||
|
found:
|
||||||
|
best_format = i;
|
||||||
|
best = format;
|
||||||
|
bestDBuffer = format.dwFlags & PFD_DOUBLEBUFFER;
|
||||||
|
bestStereo = format.dwFlags & PFD_STEREO;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE( "returning %u\n", best_format );
|
||||||
|
return best_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -933,7 +1087,6 @@ static BOOL process_attach(void)
|
||||||
wine_wgl.p_SetPixelFormat = (void *)GetProcAddress(mod_gdi32, "SetPixelFormat");
|
wine_wgl.p_SetPixelFormat = (void *)GetProcAddress(mod_gdi32, "SetPixelFormat");
|
||||||
wine_wgl.p_wglMakeCurrent = (void *)GetProcAddress(mod_gdi32, "wglMakeCurrent");
|
wine_wgl.p_wglMakeCurrent = (void *)GetProcAddress(mod_gdi32, "wglMakeCurrent");
|
||||||
wine_wgl.p_wglCreateContext = (void *)GetProcAddress(mod_gdi32, "wglCreateContext");
|
wine_wgl.p_wglCreateContext = (void *)GetProcAddress(mod_gdi32, "wglCreateContext");
|
||||||
wine_wgl.p_ChoosePixelFormat = (void *)GetProcAddress(mod_gdi32, "ChoosePixelFormat");
|
|
||||||
wine_wgl.p_DescribePixelFormat = (void *)GetProcAddress(mod_gdi32, "DescribePixelFormat");
|
wine_wgl.p_DescribePixelFormat = (void *)GetProcAddress(mod_gdi32, "DescribePixelFormat");
|
||||||
wine_wgl.p_GetPixelFormat = (void *)GetProcAddress(mod_gdi32, "GetPixelFormat");
|
wine_wgl.p_GetPixelFormat = (void *)GetProcAddress(mod_gdi32, "GetPixelFormat");
|
||||||
|
|
||||||
|
|
|
@ -1156,204 +1156,6 @@ Drawable create_glxpixmap(Display *display, XVisualInfo *vis, Pixmap parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* glxdrv_ChoosePixelFormat
|
|
||||||
*
|
|
||||||
* Equivalent to glXChooseVisual.
|
|
||||||
*/
|
|
||||||
static int glxdrv_ChoosePixelFormat(PHYSDEV dev, const PIXELFORMATDESCRIPTOR *ppfd)
|
|
||||||
{
|
|
||||||
WineGLPixelFormat *list;
|
|
||||||
int onscreen_size;
|
|
||||||
int ret = 0;
|
|
||||||
int value = 0;
|
|
||||||
int i = 0;
|
|
||||||
int bestFormat = -1;
|
|
||||||
int bestDBuffer = -1;
|
|
||||||
int bestStereo = -1;
|
|
||||||
int bestColor = -1;
|
|
||||||
int bestAlpha = -1;
|
|
||||||
int bestDepth = -1;
|
|
||||||
int bestStencil = -1;
|
|
||||||
int bestAux = -1;
|
|
||||||
|
|
||||||
if (!has_opengl()) return 0;
|
|
||||||
|
|
||||||
if (TRACE_ON(wgl)) {
|
|
||||||
TRACE("(%p,%p)\n", dev->hdc, ppfd);
|
|
||||||
|
|
||||||
dump_PIXELFORMATDESCRIPTOR(ppfd);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(list = get_formats(gdi_display, NULL, &onscreen_size ))) return 0;
|
|
||||||
|
|
||||||
wine_tsx11_lock();
|
|
||||||
for(i=0; i<onscreen_size; i++)
|
|
||||||
{
|
|
||||||
int dwFlags = 0;
|
|
||||||
int iPixelType = 0;
|
|
||||||
int alpha=0, color=0, depth=0, stencil=0, aux=0;
|
|
||||||
WineGLPixelFormat *fmt = &list[i];
|
|
||||||
|
|
||||||
/* Pixel type */
|
|
||||||
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_RENDER_TYPE, &value);
|
|
||||||
if (value & GLX_RGBA_BIT)
|
|
||||||
iPixelType = PFD_TYPE_RGBA;
|
|
||||||
else
|
|
||||||
iPixelType = PFD_TYPE_COLORINDEX;
|
|
||||||
|
|
||||||
if (ppfd->iPixelType != iPixelType)
|
|
||||||
{
|
|
||||||
TRACE("pixel type mismatch for iPixelFormat=%d\n", i+1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only use bitmap capable for formats for bitmap rendering.
|
|
||||||
* See get_formats for more info. */
|
|
||||||
if( (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) != (fmt->dwFlags & PFD_DRAW_TO_BITMAP))
|
|
||||||
{
|
|
||||||
TRACE("PFD_DRAW_TO_BITMAP mismatch for iPixelFormat=%d\n", i+1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DOUBLEBUFFER, &value);
|
|
||||||
if (value) dwFlags |= PFD_DOUBLEBUFFER;
|
|
||||||
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_STEREO, &value);
|
|
||||||
if (value) dwFlags |= PFD_STEREO;
|
|
||||||
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_BUFFER_SIZE, &color); /* cColorBits */
|
|
||||||
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ALPHA_SIZE, &alpha); /* cAlphaBits */
|
|
||||||
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DEPTH_SIZE, &depth); /* cDepthBits */
|
|
||||||
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_STENCIL_SIZE, &stencil); /* cStencilBits */
|
|
||||||
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_AUX_BUFFERS, &aux); /* cAuxBuffers */
|
|
||||||
|
|
||||||
/* The behavior of PDF_STEREO/PFD_STEREO_DONTCARE and PFD_DOUBLEBUFFER / PFD_DOUBLEBUFFER_DONTCARE
|
|
||||||
* is not very clear on MSDN. They specify that ChoosePixelFormat tries to match pixel formats
|
|
||||||
* with the flag (PFD_STEREO / PFD_DOUBLEBUFFERING) set. Otherwise it says that it tries to match
|
|
||||||
* formats without the given flag set.
|
|
||||||
* A test on Windows using a Radeon 9500pro on WinXP (the driver doesn't support Stereo)
|
|
||||||
* has indicated that a format without stereo is returned when stereo is unavailable.
|
|
||||||
* So in case PFD_STEREO is set, formats that support it should have priority above formats
|
|
||||||
* without. In case PFD_STEREO_DONTCARE is set, stereo is ignored.
|
|
||||||
*
|
|
||||||
* To summarize the following is most likely the correct behavior:
|
|
||||||
* stereo not set -> prefer no-stereo formats, else also accept stereo formats
|
|
||||||
* stereo set -> prefer stereo formats, else also accept no-stereo formats
|
|
||||||
* stereo don't care -> it doesn't matter whether we get stereo or not
|
|
||||||
*
|
|
||||||
* In Wine we will treat no-stereo the same way as don't care because it makes
|
|
||||||
* format selection even more complicated and second drivers with Stereo advertise
|
|
||||||
* each format twice anyway.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Doublebuffer, see the comments above */
|
|
||||||
if( !(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) ) {
|
|
||||||
if( ((ppfd->dwFlags & PFD_DOUBLEBUFFER) != bestDBuffer) &&
|
|
||||||
((dwFlags & PFD_DOUBLEBUFFER) == (ppfd->dwFlags & PFD_DOUBLEBUFFER)) )
|
|
||||||
goto found;
|
|
||||||
|
|
||||||
if(bestDBuffer != -1 && (dwFlags & PFD_DOUBLEBUFFER) != bestDBuffer)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Stereo, see the comments above. */
|
|
||||||
if( !(ppfd->dwFlags & PFD_STEREO_DONTCARE) ) {
|
|
||||||
if( ((ppfd->dwFlags & PFD_STEREO) != bestStereo) &&
|
|
||||||
((dwFlags & PFD_STEREO) == (ppfd->dwFlags & PFD_STEREO)) )
|
|
||||||
goto found;
|
|
||||||
|
|
||||||
if(bestStereo != -1 && (dwFlags & PFD_STEREO) != bestStereo)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Below we will do a number of checks to select the 'best' pixelformat.
|
|
||||||
* We assume the precedence cColorBits > cAlphaBits > cDepthBits > cStencilBits -> cAuxBuffers.
|
|
||||||
* The code works by trying to match the most important options as close as possible.
|
|
||||||
* When a reasonable format is found, we will try to match more options.
|
|
||||||
* It appears (see the opengl32 test) that Windows opengl drivers ignore options
|
|
||||||
* like cColorBits, cAlphaBits and friends if they are set to 0, so they are considered
|
|
||||||
* as DONTCARE. At least Serious Sam TSE relies on this behavior. */
|
|
||||||
|
|
||||||
if(ppfd->cColorBits) {
|
|
||||||
if( ((ppfd->cColorBits > bestColor) && (color > bestColor)) ||
|
|
||||||
((color >= ppfd->cColorBits) && (color < bestColor)) )
|
|
||||||
goto found;
|
|
||||||
|
|
||||||
if(bestColor != color) { /* Do further checks if the format is compatible */
|
|
||||||
TRACE("color mismatch for iPixelFormat=%d\n", i+1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ppfd->cAlphaBits) {
|
|
||||||
if( ((ppfd->cAlphaBits > bestAlpha) && (alpha > bestAlpha)) ||
|
|
||||||
((alpha >= ppfd->cAlphaBits) && (alpha < bestAlpha)) )
|
|
||||||
goto found;
|
|
||||||
|
|
||||||
if(bestAlpha != alpha) {
|
|
||||||
TRACE("alpha mismatch for iPixelFormat=%d\n", i+1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ppfd->cDepthBits) {
|
|
||||||
if( ((ppfd->cDepthBits > bestDepth) && (depth > bestDepth)) ||
|
|
||||||
((depth >= ppfd->cDepthBits) && (depth < bestDepth)) )
|
|
||||||
goto found;
|
|
||||||
|
|
||||||
if(bestDepth != depth) {
|
|
||||||
TRACE("depth mismatch for iPixelFormat=%d\n", i+1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ppfd->cStencilBits) {
|
|
||||||
if( ((ppfd->cStencilBits > bestStencil) && (stencil > bestStencil)) ||
|
|
||||||
((stencil >= ppfd->cStencilBits) && (stencil < bestStencil)) )
|
|
||||||
goto found;
|
|
||||||
|
|
||||||
if(bestStencil != stencil) {
|
|
||||||
TRACE("stencil mismatch for iPixelFormat=%d\n", i+1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ppfd->cAuxBuffers) {
|
|
||||||
if( ((ppfd->cAuxBuffers > bestAux) && (aux > bestAux)) ||
|
|
||||||
((aux >= ppfd->cAuxBuffers) && (aux < bestAux)) )
|
|
||||||
goto found;
|
|
||||||
|
|
||||||
if(bestAux != aux) {
|
|
||||||
TRACE("aux mismatch for iPixelFormat=%d\n", i+1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
|
|
||||||
found:
|
|
||||||
bestDBuffer = dwFlags & PFD_DOUBLEBUFFER;
|
|
||||||
bestStereo = dwFlags & PFD_STEREO;
|
|
||||||
bestAlpha = alpha;
|
|
||||||
bestColor = color;
|
|
||||||
bestDepth = depth;
|
|
||||||
bestStencil = stencil;
|
|
||||||
bestAux = aux;
|
|
||||||
bestFormat = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(bestFormat == -1) {
|
|
||||||
TRACE("No matching mode was found returning 0\n");
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ret = bestFormat+1; /* the return value should be a 1-based index */
|
|
||||||
TRACE("Successfully found a matching mode, returning index: %d %x\n", ret, list[bestFormat].fmt_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
wine_tsx11_unlock();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* glxdrv_DescribePixelFormat
|
* glxdrv_DescribePixelFormat
|
||||||
*
|
*
|
||||||
|
@ -3654,7 +3456,7 @@ static const struct gdi_dc_funcs glxdrv_funcs =
|
||||||
NULL, /* pArcTo */
|
NULL, /* pArcTo */
|
||||||
NULL, /* pBeginPath */
|
NULL, /* pBeginPath */
|
||||||
NULL, /* pBlendImage */
|
NULL, /* pBlendImage */
|
||||||
glxdrv_ChoosePixelFormat, /* pChoosePixelFormat */
|
NULL, /* pChoosePixelFormat */
|
||||||
NULL, /* pChord */
|
NULL, /* pChord */
|
||||||
NULL, /* pCloseFigure */
|
NULL, /* pCloseFigure */
|
||||||
glxdrv_CreateCompatibleDC, /* pCreateCompatibleDC */
|
glxdrv_CreateCompatibleDC, /* pCreateCompatibleDC */
|
||||||
|
|
Loading…
Reference in New Issue