Stefan Dösinger : wined3d: Do not fail if the adapter info can't be initialized.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Jul 26 06:36:57 CDT 2007
Module: wine
Branch: master
Commit: 12788f6fc8987687453092cb3914fb46f2a4e4d1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=12788f6fc8987687453092cb3914fb46f2a4e4d1
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Mon Jul 16 20:53:44 2007 +0200
wined3d: Do not fail if the adapter info can't be initialized.
---
dlls/wined3d/device.c | 8 +++++++-
dlls/wined3d/directx.c | 8 +++++---
dlls/wined3d/wined3d_main.c | 7 +++++--
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index d795e25..9f6d63b 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -716,7 +716,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
/* Look at the implementation and set the correct Vtable */
switch(Impl) {
case SURFACE_OPENGL:
- /* Nothing to do, it's set already */
+ /* Check if a 3D adapter is available when creating gl surfaces */
+ if(!This->adapter) {
+ ERR("OpenGL surfaces are not available without opengl\n");
+ HeapFree(GetProcessHeap(), 0, object->resource.allocatedMemory);
+ HeapFree(GetProcessHeap(), 0, object);
+ return WINED3DERR_NOTAVAILABLE;
+ }
break;
case SURFACE_GDI:
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 86eb0cc..1dfb16d 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -2418,8 +2418,10 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
HDC hDC;
int i;
- /* Validate the adapter number */
- if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
+ /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
+ * number and create a device without a 3D adapter for 2D only operation.
+ */
+ if (IWineD3D_GetAdapterCount(iface) && Adapter >= IWineD3D_GetAdapterCount(iface)) {
return WINED3DERR_INVALIDCALL;
}
@@ -2435,7 +2437,7 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
object->lpVtbl = &IWineD3DDevice_Vtbl;
object->ref = 1;
object->wineD3D = iface;
- object->adapter = &Adapters[Adapter];
+ object->adapter = numAdapters ? &Adapters[Adapter] : NULL;
IWineD3D_AddRef(object->wineD3D);
object->parent = parent;
diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c
index d232a2b..d1cf28a 100644
--- a/dlls/wined3d/wined3d_main.c
+++ b/dlls/wined3d/wined3d_main.c
@@ -62,8 +62,11 @@ IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *p
IWineD3DImpl* object;
if (!InitAdapters()) {
- ERR("Failed to initialize direct3d adapters\n");
- return NULL;
+ WARN("Failed to initialize direct3d adapters, Direct3D will not be available\n");
+ if(dxVersion > 7) {
+ ERR("Direct3D%d is not available without opengl\n", dxVersion);
+ return NULL;
+ }
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DImpl));
More information about the wine-cvs
mailing list