Commit 5ce986f1 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Add a separate function for wined3d object initialization.

parent 57fb1633
......@@ -5020,7 +5020,7 @@ static void fillGLAttribFuncs(const struct wined3d_gl_info *gl_info)
}
}
BOOL InitAdapters(IWineD3DImpl *This)
static BOOL InitAdapters(IWineD3DImpl *This)
{
static HMODULE mod_gl;
BOOL ret;
......@@ -5318,7 +5318,7 @@ nogl_adapter:
* IWineD3D VTbl follows
**********************************************************/
const IWineD3DVtbl IWineD3D_Vtbl =
static const struct IWineD3DVtbl IWineD3D_Vtbl =
{
/* IUnknown */
IWineD3DImpl_QueryInterface,
......@@ -5348,3 +5348,23 @@ const struct wined3d_parent_ops wined3d_null_parent_ops =
{
wined3d_null_wined3d_object_destroyed,
};
HRESULT wined3d_init(IWineD3DImpl *wined3d, UINT version, IUnknown *parent)
{
wined3d->lpVtbl = &IWineD3D_Vtbl;
wined3d->dxVersion = version;
wined3d->ref = 1;
wined3d->parent = parent;
if (!InitAdapters(wined3d))
{
WARN("Failed to initialize adapters.\n");
if (version > 7)
{
MESSAGE("Direct3D%u is not available without OpenGL.\n", version);
return E_FAIL;
}
}
return WINED3D_OK;
}
......@@ -75,27 +75,27 @@ wined3d_settings_t wined3d_settings =
FALSE /* Disable multisampling for now due to Nvidia driver bugs which happens for some users */
};
IWineD3D* WINAPI WineDirect3DCreate(UINT dxVersion, IUnknown *parent) {
IWineD3DImpl* object;
IWineD3D * WINAPI WineDirect3DCreate(UINT version, IUnknown *parent)
{
IWineD3DImpl *object;
HRESULT hr;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DImpl));
object->lpVtbl = &IWineD3D_Vtbl;
object->dxVersion = dxVersion;
object->ref = 1;
object->parent = parent;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
ERR("Failed to allocate wined3d object memory.\n");
return NULL;
}
if (!InitAdapters(object))
hr = wined3d_init(object, version, parent);
if (FAILED(hr))
{
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);
HeapFree(GetProcessHeap(), 0, object);
return NULL;
}
WARN("Failed to initialize wined3d object, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return NULL;
}
TRACE("Created WineD3D object @ %p for d3d%d support\n", object, dxVersion);
TRACE("Created wined3d object %p for d3d%d support.\n", object, version);
return (IWineD3D *)object;
}
......@@ -120,7 +120,7 @@ static void CDECL wined3d_do_nothing(void)
{
}
static BOOL wined3d_init(HINSTANCE hInstDLL)
static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
{
DWORD wined3d_context_tls_idx;
HMODULE mod;
......@@ -333,7 +333,7 @@ static BOOL wined3d_init(HINSTANCE hInstDLL)
return TRUE;
}
static BOOL wined3d_destroy(HINSTANCE hInstDLL)
static BOOL wined3d_dll_destroy(HINSTANCE hInstDLL)
{
DWORD wined3d_context_tls_idx = context_get_tls_idx();
unsigned int i;
......@@ -473,10 +473,10 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
return wined3d_init(hInstDLL);
return wined3d_dll_init(hInstDLL);
case DLL_PROCESS_DETACH:
return wined3d_destroy(hInstDLL);
return wined3d_dll_destroy(hInstDLL);
case DLL_THREAD_DETACH:
{
......
......@@ -1567,11 +1567,9 @@ typedef struct IWineD3DImpl
struct wined3d_adapter adapters[1];
} IWineD3DImpl;
extern const IWineD3DVtbl IWineD3D_Vtbl DECLSPEC_HIDDEN;
HRESULT wined3d_init(IWineD3DImpl *wined3d, UINT version, IUnknown *parent) DECLSPEC_HIDDEN;
BOOL wined3d_register_window(HWND window, struct IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
BOOL InitAdapters(IWineD3DImpl *This) DECLSPEC_HIDDEN;
/* A helper function that dumps a resource list */
void dumpResources(struct list *list) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment