diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 2a80636a4e8..798f310315c 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1402,6 +1402,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateAdditionalSwapChain(IWineD3DDevic HRESULT hr = WINED3D_OK; IUnknown *bufferParent; BOOL displaymode_set = FALSE; + WINED3DDISPLAYMODE Mode; + const StaticPixelFormatDesc *formatDesc; TRACE("(%p) : Created Aditional Swap Chain\n", This); @@ -1439,10 +1441,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateAdditionalSwapChain(IWineD3DDevic return WINED3DERR_NOTAVAILABLE; } - object->orig_width = GetSystemMetrics(SM_CXSCREEN); - object->orig_height = GetSystemMetrics(SM_CYSCREEN); - object->orig_fmt = pixelformat_for_depth(GetDeviceCaps(hDc, BITSPIXEL) * GetDeviceCaps(hDc, PLANES)); - ReleaseDC(object->win_handle, hDc); + /* Get info on the current display setup */ + IWineD3D_GetAdapterDisplayMode(This->wineD3D, This->adapter->num, &Mode); + object->orig_width = Mode.Width; + object->orig_height = Mode.Height; + object->orig_fmt = Mode.Format; + formatDesc = getFormatDescEntry(Mode.Format, NULL, NULL); /** MSDN: If Windowed is TRUE and either of the BackBufferWidth/Height values is zero, * then the corresponding dimension of the client area of the hDeviceWindow @@ -1507,14 +1511,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateAdditionalSwapChain(IWineD3DDevic if (!pPresentationParameters->Windowed) { DEVMODEW devmode; - HDC hdc; int bpp = 0; RECT clip_rc; - /* Get info on the current display setup */ - hdc = GetDC(0); - bpp = GetDeviceCaps(hdc, BITSPIXEL); - ReleaseDC(0, hdc); + bpp = formatDesc->bpp * 8; /* Change the display settings */ memset(&devmode, 0, sizeof(devmode)); @@ -1641,23 +1641,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateAdditionalSwapChain(IWineD3DDevic error: if (displaymode_set) { DEVMODEW devmode; - HDC hdc; - int bpp = 0; RECT clip_rc; SetRect(&clip_rc, 0, 0, object->orig_width, object->orig_height); ClipCursor(NULL); - /* Get info on the current display setup */ - hdc = GetDC(0); - bpp = GetDeviceCaps(hdc, BITSPIXEL); - ReleaseDC(0, hdc); - /* Change the display settings */ memset(&devmode, 0, sizeof(devmode)); devmode.dmSize = sizeof(devmode); devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - devmode.dmBitsPerPel = (bpp >= 24) ? 32 : bpp; /* Stupid XVidMode cannot change bpp */ + devmode.dmBitsPerPel = (formatDesc->bpp >= 3) ? 32 : formatDesc->bpp * 8; /* Stupid XVidMode cannot change bpp */ devmode.dmPelsWidth = object->orig_width; devmode.dmPelsHeight = object->orig_height; ChangeDisplaySettingsExW(This->adapter->DeviceName, &devmode, NULL, CDS_FULLSCREEN, NULL); diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 43d2a794d39..71525a0cde5 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -2698,7 +2698,7 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, IWineD3DDeviceImpl *object = NULL; IWineD3DImpl *This = (IWineD3DImpl *)iface; - HDC hDC; + WINED3DDISPLAYMODE mode; int i; /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter @@ -2762,11 +2762,11 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, object->state = WINED3D_OK; /* Get the initial screen setup for ddraw */ - object->ddraw_width = GetSystemMetrics(SM_CXSCREEN); - object->ddraw_height = GetSystemMetrics(SM_CYSCREEN); - hDC = GetDC(0); - object->ddraw_format = pixelformat_for_depth(GetDeviceCaps(hDC, BITSPIXEL) * GetDeviceCaps(hDC, PLANES)); - ReleaseDC(0, hDC); + IWineD3DImpl_GetAdapterDisplayMode(iface, Adapter, &mode); + + object->ddraw_width = mode.Width; + object->ddraw_height = mode.Height; + object->ddraw_format = mode.Format; for(i = 0; i < PATCHMAP_SIZE; i++) { list_init(&object->patches[i]); @@ -2933,6 +2933,7 @@ BOOL InitAdapters(void) { HDC hdc; TRACE("Initializing default adapter\n"); + Adapters[0].num = 0; Adapters[0].monitorPoint.x = -1; Adapters[0].monitorPoint.y = -1; diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index d27e7077a5d..28fd54bf1da 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -464,30 +464,14 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *i static HRESULT WINAPI IWineD3DSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, WINED3DDISPLAYMODE*pMode) { IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface; - HDC hdc; - int bpp = 0; + HRESULT hr; - pMode->Width = GetSystemMetrics(SM_CXSCREEN); - pMode->Height = GetSystemMetrics(SM_CYSCREEN); - pMode->RefreshRate = 85; /* FIXME: How to identify? */ - - hdc = GetDC(0); - bpp = GetDeviceCaps(hdc, BITSPIXEL); - ReleaseDC(0, hdc); - - switch (bpp) { - case 8: pMode->Format = WINED3DFMT_R8G8B8; break; - case 16: pMode->Format = WINED3DFMT_R5G6B5; break; - case 24: /*pMode->Format = WINED3DFMT_R8G8B8; break; */ /* 32bpp and 24bpp can be aliased for X */ - case 32: pMode->Format = WINED3DFMT_A8R8G8B8; break; - default: - FIXME("Unrecognized display mode format\n"); - pMode->Format = WINED3DFMT_UNKNOWN; - } + TRACE("(%p)->(%p): Calling GetAdapterDisplayMode\n", This, pMode); + hr = IWineD3D_GetAdapterDisplayMode(This->wineD3DDevice->wineD3D, This->wineD3DDevice->adapter->num, pMode); TRACE("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate, pMode->Format, debug_d3dformat(pMode->Format)); - return WINED3D_OK; + return hr; } static HRESULT WINAPI IWineD3DSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3DDevice**ppDevice) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 6806bfec6cc..6207162aad8 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -574,6 +574,7 @@ typedef struct WineD3D_PixelFormat typedef struct GLPixelFormatDesc GLPixelFormatDesc; struct WineD3DAdapter { + UINT num; POINT monitorPoint; WineD3D_GL_Info gl_info; const char *driver;