* Sync up to trunk head (r60691).
[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 return NULL;
44
45 if (!d3d9_init(object, FALSE))
46 {
47 WARN("Failed to initialize d3d9.\n");
48 HeapFree(GetProcessHeap(), 0, object);
49 return NULL;
50 }
51
52 TRACE("Created d3d9 object %p.\n", object);
53
54 return (IDirect3D9 *)&object->IDirect3D9Ex_iface;
55 }
56
57 HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9Ex **d3d9ex)
58 {
59 struct d3d9 *object;
60
61 TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version, d3d9ex);
62
63 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
64 return E_OUTOFMEMORY;
65
66 if (!d3d9_init(object, TRUE))
67 {
68 WARN("Failed to initialize d3d9.\n");
69 HeapFree(GetProcessHeap(), 0, object);
70 return D3DERR_NOTAVAILABLE;
71 }
72
73 TRACE("Created d3d9 object %p.\n", object);
74 *d3d9ex = &object->IDirect3D9Ex_iface;
75
76 return D3D_OK;
77 }
78
79 /*******************************************************************
80 * Direct3DShaderValidatorCreate9 (D3D9.@)
81 *
82 * No documentation available for this function.
83 * SDK only says it is internal and shouldn't be used.
84 */
85 void* WINAPI Direct3DShaderValidatorCreate9(void)
86 {
87 static int once;
88
89 if (!once++) 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 TRACE("(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 TRACE("(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 }