wined3d: Add a classic WGL pixel format backend as not all OpenGL implementations support WGL_ARB_pixel_format.

This should help for instance VirtualBox.
This commit is contained in:
Roderick Colenbrander 2009-03-15 11:30:10 +01:00 committed by Alexandre Julliard
parent 9181ddcd16
commit 4544efc972
1 changed files with 114 additions and 56 deletions

View File

@ -4301,13 +4301,9 @@ BOOL InitAdapters(IWineD3DImpl *This)
struct WineD3DAdapter *adapter = &This->adapters[0];
const WineD3D_GL_Info *gl_info = &adapter->gl_info;
int iPixelFormat;
int attribs[10];
int values[10];
int nAttribs = 0;
int res;
int i;
WineD3D_PixelFormat *cfgs;
int attribute;
DISPLAY_DEVICEW DisplayDevice;
HDC hdc;
@ -4359,6 +4355,13 @@ BOOL InitAdapters(IWineD3DImpl *This)
TRACE("DeviceName: %s\n", debugstr_w(DisplayDevice.DeviceName));
strcpyW(adapter->DeviceName, DisplayDevice.DeviceName);
if(GL_SUPPORT(WGL_ARB_PIXEL_FORMAT))
{
int attribute;
int attribs[10];
int values[10];
int nAttribs = 0;
attribute = WGL_NUMBER_PIXEL_FORMATS_ARB;
GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, &attribute, &adapter->nCfgs));
@ -4420,6 +4423,61 @@ BOOL InitAdapters(IWineD3DImpl *This)
TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, depth=%d, stencil=%d, windowDrawable=%d, pbufferDrawable=%d\n", cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer, cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize, cfgs->depthSize, cfgs->stencilSize, cfgs->windowDrawable, cfgs->pbufferDrawable);
cfgs++;
}
}
else
{
int nCfgs = DescribePixelFormat(hdc, 0, 0, 0);
adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nCfgs*sizeof(WineD3D_PixelFormat));
adapter->nCfgs = 0; /* We won't accept all formats e.g. software accelerated ones will be skipped */
cfgs = adapter->cfgs;
for(iPixelFormat=1; iPixelFormat<=nCfgs; iPixelFormat++)
{
PIXELFORMATDESCRIPTOR ppfd;
res = DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &ppfd);
if(!res)
continue;
/* We only want HW acceleration using an OpenGL ICD driver.
* PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering
* PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD driver (e.g. 3dfx minigl)
*/
if(ppfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED))
{
TRACE("Skipping iPixelFormat=%d because it isn't ICD accelerated\n", iPixelFormat);
continue;
}
cfgs->iPixelFormat = iPixelFormat;
cfgs->redSize = ppfd.cRedBits;
cfgs->greenSize = ppfd.cGreenBits;
cfgs->blueSize = ppfd.cBlueBits;
cfgs->alphaSize = ppfd.cAlphaBits;
cfgs->depthSize = ppfd.cDepthBits;
cfgs->stencilSize = ppfd.cStencilBits;
cfgs->pbufferDrawable = 0;
cfgs->windowDrawable = (ppfd.dwFlags & PFD_DRAW_TO_WINDOW) ? 1 : 0;
cfgs->iPixelType = (ppfd.iPixelType == PFD_TYPE_RGBA) ? WGL_TYPE_RGBA_ARB : WGL_TYPE_COLORINDEX_ARB;
cfgs->doubleBuffer = (ppfd.dwFlags & PFD_DOUBLEBUFFER) ? 1 : 0;
cfgs->auxBuffers = ppfd.cAuxBuffers;
cfgs->numSamples = 0;
TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, depth=%d, stencil=%d, windowDrawable=%d, pbufferDrawable=%d\n", cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer, cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize, cfgs->depthSize, cfgs->stencilSize, cfgs->windowDrawable, cfgs->pbufferDrawable);
cfgs++;
adapter->nCfgs++;
}
/* Yikes we haven't found any suitable formats. This should only happen in case of GDI software rendering which we can't use anyway as its 3D functionality is very, very limited */
if(!adapter->nCfgs)
{
ERR("Disabling Direct3D because no hardware accelerated pixel formats have been found!\n");
WineD3D_ReleaseFakeGLContext();
HeapFree(GetProcessHeap(), 0, adapter->cfgs);
goto nogl_adapter;
}
}
/* D16, D24X8 and D24S8 are common depth / depth+stencil formats. All drivers support them though this doesn't
* mean that the format is offered in hardware. For instance Geforce8 cards don't have offer D16 in hardware