d3dxof: Cleanup IDirectXFileImpl_CreateEnumObject a bit.
[wine] / dlls / d3d9 / d3d9_main.c
1 /*
2  * Direct3D 9
3  *
4  * Copyright 2002-2003 Jason Edmeades
5  * Copyright 2002-2003 Raphael Junqueira
6  * Copyright 2005 Oliver Stieber
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  *
22  */
23
24 #include "config.h"
25 #include "initguid.h"
26 #include "d3d9_private.h"
27
28 static CRITICAL_SECTION_DEBUG d3d9_cs_debug =
29 {
30     0, 0, &d3d9_cs,
31     { &d3d9_cs_debug.ProcessLocksList,
32     &d3d9_cs_debug.ProcessLocksList },
33     0, 0, { (DWORD_PTR)(__FILE__ ": d3d9_cs") }
34 };
35 CRITICAL_SECTION d3d9_cs = { &d3d9_cs_debug, -1, 0, 0, 0, 0 };
36
37 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
38
39 static int D3DPERF_event_level = 0;
40
41 void WINAPI DebugSetMute(void) {
42     /* nothing to do */
43 }
44
45 IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) {
46     IDirect3D9Impl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D9Impl));
47
48     object->lpVtbl = &Direct3D9_Vtbl;
49     object->ref = 1;
50     EnterCriticalSection(&d3d9_cs);
51     object->WineD3D = WineDirect3DCreate(9, (IUnknown *)object);
52     LeaveCriticalSection(&d3d9_cs);
53
54     TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
55
56     if (!object->WineD3D)
57     {
58         HeapFree( GetProcessHeap(), 0, object );
59         object = NULL;
60     }
61     return (IDirect3D9*) object;
62 }
63
64 HRESULT WINAPI Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex **direct3d9ex) {
65     IDirect3D9 *ret;
66     IDirect3D9Impl* object;
67
68     TRACE("Calling Direct3DCreate9\n");
69     ret = Direct3DCreate9(SDKVersion);
70     if(!ret) {
71         *direct3d9ex = NULL;
72         return D3DERR_NOTAVAILABLE;
73     }
74
75     object = (IDirect3D9Impl *) ret;
76     object->extended = TRUE; /* Enables QI for extended interfaces */
77     *direct3d9ex = (IDirect3D9Ex *) object;
78     return D3D_OK;
79 }
80
81 /*******************************************************************
82  *       Direct3DShaderValidatorCreate9 (D3D9.@)
83  *
84  * No documentation available for this function.
85  * SDK only says it is internal and shouldn't be used.
86  */
87 void* WINAPI Direct3DShaderValidatorCreate9(void)
88 {
89     FIXME("stub\n");
90     return NULL;
91 }
92
93 /*******************************************************************
94  *       DllMain
95  */
96 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
97 {
98     /* At process attach */
99     TRACE("fdwReason=%d\n", fdwReason);
100     if (fdwReason == DLL_PROCESS_ATTACH)
101         DisableThreadLibraryCalls(hInstDLL);
102
103     return TRUE;
104 }
105
106 /***********************************************************************
107  *              D3DPERF_BeginEvent (D3D9.@)
108  */
109 int WINAPI D3DPERF_BeginEvent(D3DCOLOR color, LPCWSTR name) {
110     FIXME("(color %#x, name %s) : stub\n", color, debugstr_w(name));
111
112     return D3DPERF_event_level++;
113 }
114
115 /***********************************************************************
116  *              D3DPERF_EndEvent (D3D9.@)
117  */
118 int WINAPI D3DPERF_EndEvent(void) {
119     FIXME("(void) : stub\n");
120
121     return --D3DPERF_event_level;
122 }
123
124 /***********************************************************************
125  *              D3DPERF_GetStatus (D3D9.@)
126  */
127 DWORD WINAPI D3DPERF_GetStatus(void) {
128     FIXME("(void) : stub\n");
129
130     return 0;
131 }
132
133 /***********************************************************************
134  *              D3DPERF_SetOptions (D3D9.@)
135  *
136  */
137 void WINAPI D3DPERF_SetOptions(DWORD options)
138 {
139   FIXME("(%#x) : stub\n", options);
140 }
141
142 /***********************************************************************
143  *              D3DPERF_QueryRepeatFrame (D3D9.@)
144  */
145 BOOL WINAPI D3DPERF_QueryRepeatFrame(void) {
146     FIXME("(void) : stub\n");
147
148     return FALSE;
149 }
150
151 /***********************************************************************
152  *              D3DPERF_SetMarker (D3D9.@)
153  */
154 void WINAPI D3DPERF_SetMarker(D3DCOLOR color, LPCWSTR name) {
155     FIXME("(color %#x, name %s) : stub\n", color, debugstr_w(name));
156 }
157
158 /***********************************************************************
159  *              D3DPERF_SetRegion (D3D9.@)
160  */
161 void WINAPI D3DPERF_SetRegion(D3DCOLOR color, LPCWSTR name) {
162     FIXME("(color %#x, name %s) : stub\n", color, debugstr_w(name));
163 }