Synchronize with trunk's revision r57599.
[reactos.git] / dll / directx / wine / 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 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
29
30 static int D3DPERF_event_level = 0;
31
32 void WINAPI DebugSetMute(void) {
33 /* nothing to do */
34 }
35
36 IDirect3D9 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT sdk_version)
37 {
38 struct d3d9 *object;
39
40 TRACE("sdk_version %#x.\n", sdk_version);
41
42 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
43 {
44 ERR("Failed to allocate d3d9 object memory.\n");
45 return NULL;
46 }
47
48 if (!d3d9_init(object, FALSE))
49 {
50 WARN("Failed to initialize d3d9.\n");
51 HeapFree(GetProcessHeap(), 0, object);
52 return NULL;
53 }
54
55 TRACE("Created d3d9 object %p.\n", object);
56
57 return (IDirect3D9 *)&object->IDirect3D9Ex_iface;
58 }
59
60 HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9Ex **d3d9ex)
61 {
62 struct d3d9 *object;
63
64 TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version, d3d9ex);
65
66 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
67 {
68 ERR("Failed to allocate d3d9 object memory.\n");
69 return E_OUTOFMEMORY;
70 }
71
72 if (!d3d9_init(object, TRUE))
73 {
74 WARN("Failed to initialize d3d9.\n");
75 HeapFree(GetProcessHeap(), 0, object);
76 return D3DERR_NOTAVAILABLE;
77 }
78
79 TRACE("Created d3d9 object %p.\n", object);
80 *d3d9ex = &object->IDirect3D9Ex_iface;
81
82 return D3D_OK;
83 }
84
85 /*******************************************************************
86 * Direct3DShaderValidatorCreate9 (D3D9.@)
87 *
88 * No documentation available for this function.
89 * SDK only says it is internal and shouldn't be used.
90 */
91 void* WINAPI Direct3DShaderValidatorCreate9(void)
92 {
93 static int once;
94
95 if (!once++) FIXME("stub\n");
96 return NULL;
97 }
98
99 /*******************************************************************
100 * DllMain
101 */
102 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
103 {
104 /* At process attach */
105 TRACE("fdwReason=%d\n", fdwReason);
106 if (fdwReason == DLL_PROCESS_ATTACH)
107 DisableThreadLibraryCalls(hInstDLL);
108
109 return TRUE;
110 }
111
112 /***********************************************************************
113 * D3DPERF_BeginEvent (D3D9.@)
114 */
115 int WINAPI D3DPERF_BeginEvent(D3DCOLOR color, LPCWSTR name) {
116 TRACE("(color %#x, name %s) : stub\n", color, debugstr_w(name));
117
118 return D3DPERF_event_level++;
119 }
120
121 /***********************************************************************
122 * D3DPERF_EndEvent (D3D9.@)
123 */
124 int WINAPI D3DPERF_EndEvent(void) {
125 TRACE("(void) : stub\n");
126
127 return --D3DPERF_event_level;
128 }
129
130 /***********************************************************************
131 * D3DPERF_GetStatus (D3D9.@)
132 */
133 DWORD WINAPI D3DPERF_GetStatus(void) {
134 FIXME("(void) : stub\n");
135
136 return 0;
137 }
138
139 /***********************************************************************
140 * D3DPERF_SetOptions (D3D9.@)
141 *
142 */
143 void WINAPI D3DPERF_SetOptions(DWORD options)
144 {
145 FIXME("(%#x) : stub\n", options);
146 }
147
148 /***********************************************************************
149 * D3DPERF_QueryRepeatFrame (D3D9.@)
150 */
151 BOOL WINAPI D3DPERF_QueryRepeatFrame(void) {
152 FIXME("(void) : stub\n");
153
154 return FALSE;
155 }
156
157 /***********************************************************************
158 * D3DPERF_SetMarker (D3D9.@)
159 */
160 void WINAPI D3DPERF_SetMarker(D3DCOLOR color, LPCWSTR name) {
161 FIXME("(color %#x, name %s) : stub\n", color, debugstr_w(name));
162 }
163
164 /***********************************************************************
165 * D3DPERF_SetRegion (D3D9.@)
166 */
167 void WINAPI D3DPERF_SetRegion(D3DCOLOR color, LPCWSTR name) {
168 FIXME("(color %#x, name %s) : stub\n", color, debugstr_w(name));
169 }