shlwapi/tests: Fix some failures on XP and W2K3.
[wine/multimedia.git] / dlls / d3d10 / d3d10_main.c
blob57280355fa3f14c14738c324c6cb20d340b11395
1 /*
2 * Direct3D 10
4 * Copyright 2007 Andras Kovacs
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include "wine/port.h"
25 #include "d3d10_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
29 /* At process attach */
30 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
32 TRACE("fdwReason=%d\n", fdwReason);
33 switch(fdwReason)
35 case DLL_PROCESS_ATTACH:
36 DisableThreadLibraryCalls( hInstDLL );
37 break;
39 return TRUE;
42 HRESULT WINAPI D3D10CreateDevice(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type,
43 HMODULE swrast, UINT flags, UINT sdk_version, ID3D10Device **device)
45 struct d3d10_device *object;
47 FIXME("adapter %p, driver_type %s, swrast %p, flags %#x, sdk_version %d, device %p partial stub!\n",
48 adapter, debug_d3d10_driver_type(driver_type), swrast, flags, sdk_version, device);
50 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
51 if (!object)
53 ERR("Failed to allocate D3D device object memory\n");
54 return E_OUTOFMEMORY;
57 object->vtbl = &d3d10_device_vtbl;
58 object->refcount = 1;
59 *device = (ID3D10Device *)object;
61 TRACE("Created ID3D10Device %p\n", object);
63 return S_OK;
66 HRESULT WINAPI D3D10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type,
67 HMODULE swrast, UINT flags, UINT sdk_version, DXGI_SWAP_CHAIN_DESC *swapchain_desc,
68 IDXGISwapChain **swapchain, ID3D10Device **device)
70 IDXGIFactory *factory;
71 HRESULT hr;
73 TRACE("adapter %p, driver_type %s, swrast %p, flags %#x, sdk_version %d,\n"
74 "\tswapchain_desc %p, swapchain %p, device %p\n",
75 adapter, debug_d3d10_driver_type(driver_type), swrast, flags, sdk_version,
76 swapchain_desc, swapchain, device);
78 hr = D3D10CreateDevice(adapter, driver_type, swrast, flags, sdk_version, device);
79 if (FAILED(hr))
81 WARN("Failed to create a device, returning %#x\n", hr);
82 return hr;
85 TRACE("Created ID3D10Device %p\n", *device);
87 hr = CreateDXGIFactory(&IID_IDXGIFactory, (void **)&factory);
88 if (FAILED(hr))
90 ID3D10Device_Release(*device);
91 *device = NULL;
93 WARN("Failed to create a DXGI factory, returning %#x\n", hr);
94 return hr;
97 TRACE("Created IDXGIFactory %p\n", factory);
99 hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)*device, swapchain_desc, swapchain);
100 IDXGIFactory_Release(factory);
101 if (FAILED(hr))
103 ID3D10Device_Release(*device);
104 *device = NULL;
106 WARN("Failed to create a swapchain, returning %#x\n", hr);
107 return hr;
110 TRACE("Created IDXGISwapChain %p\n", *swapchain);
112 return S_OK;