diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 15a6fc8ceca..667ee6c80f0 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1786,8 +1786,26 @@ HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface) { } HRESULT WINAPI IWineD3DDeviceImpl_EnumDisplayModes(IWineD3DDevice *iface, DWORD Flags, UINT Width, UINT Height, WINED3DFORMAT pixelformat, LPVOID context, D3DCB_ENUMDISPLAYMODESCALLBACK callback) { - FIXME("This call is a d3d7 merge stub. It will be implemented later\n"); - return WINED3DERR_INVALIDCALL; + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + + DEVMODEW DevModeW; + int i; + + TRACE("(%p)->(%lx,%d,%d,%d,%p,%p)\n", This, Flags, Width, Height, pixelformat, context, callback); + + for (i = 0; EnumDisplaySettingsExW(NULL, i, &DevModeW, 0); i++) { + /* Ignore some modes if a description was passed */ + if ( (Width > 0) && (Width != DevModeW.dmPelsWidth)) continue; + if ( (Height > 0) && (Height != DevModeW.dmPelsHeight)) continue; + if ( (pixelformat != WINED3DFMT_UNKNOWN) && ( D3DFmtGetBpp(NULL, pixelformat) != DevModeW.dmBitsPerPel) ) continue; + + TRACE("Enumerating %ldx%ld@%s\n", DevModeW.dmPelsWidth, DevModeW.dmPelsHeight, debug_d3dformat(pixelformat_for_depth(DevModeW.dmBitsPerPel))); + + if (callback((IUnknown *) This, (UINT) DevModeW.dmPelsWidth, (UINT) DevModeW.dmPelsHeight, pixelformat_for_depth(DevModeW.dmBitsPerPel), 60.0, context) == DDENUMRET_CANCEL) + return D3D_OK; + } + + return D3D_OK; } HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, UINT iSwapChain, WINED3DDISPLAYMODE* pMode) { diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index b38db422270..cfc244a7263 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -2041,3 +2041,15 @@ int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, i } #undef GLINFO_LOCATION + +/* DirectDraw stuff */ +WINED3DFORMAT pixelformat_for_depth(DWORD depth) { + switch(depth) { + case 8: return D3DFMT_P8; break; + case 15: return WINED3DFMT_X1R5G5B5; break; + case 16: return WINED3DFMT_R5G6B5; break; + case 24: return WINED3DFMT_R8G8B8; break; + case 32: return WINED3DFMT_X8R8G8B8; break; + default: return WINED3DFMT_UNKNOWN; + } +} diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 0553998b431..afb769c2152 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1283,4 +1283,7 @@ struct IWineD3DPaletteImpl { extern const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl; +/* DirectDraw utility functions */ +extern WINED3DFORMAT pixelformat_for_depth(DWORD depth); + #endif