netapi32: Remove DECLSPEC_HIDDEN usage.
[wine.git] / dlls / d3dx9_36 / line.c
blob8cf17eb9511f4ec205159a8131c169b21e4223f1
1 /*
2 * Copyright 2010 Christian Costa
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "d3dx9_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
25 struct d3dx9_line
27 ID3DXLine ID3DXLine_iface;
28 LONG ref;
30 IDirect3DDevice9 *device;
31 IDirect3DStateBlock9 *state;
32 float width;
35 static inline struct d3dx9_line *impl_from_ID3DXLine(ID3DXLine *iface)
37 return CONTAINING_RECORD(iface, struct d3dx9_line, ID3DXLine_iface);
40 static HRESULT WINAPI d3dx9_line_QueryInterface(ID3DXLine *iface, REFIID riid, void **out)
42 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
44 if (IsEqualGUID(riid, &IID_ID3DXLine)
45 || IsEqualGUID(riid, &IID_IUnknown))
47 ID3DXLine_AddRef(iface);
48 *out = iface;
49 return S_OK;
52 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
54 *out = NULL;
55 return E_NOINTERFACE;
58 static ULONG WINAPI d3dx9_line_AddRef(ID3DXLine *iface)
60 struct d3dx9_line *line = impl_from_ID3DXLine(iface);
61 ULONG refcount = InterlockedIncrement(&line->ref);
63 TRACE("%p increasing refcount to %lu.\n", line, refcount);
65 return refcount;
68 static ULONG WINAPI d3dx9_line_Release(ID3DXLine *iface)
70 struct d3dx9_line *line = impl_from_ID3DXLine(iface);
71 ULONG refcount = InterlockedDecrement(&line->ref);
73 TRACE("%p decreasing refcount to %lu.\n", line, refcount);
75 if (!refcount)
77 IDirect3DDevice9_Release(line->device);
78 HeapFree(GetProcessHeap(), 0, line);
81 return refcount;
84 static HRESULT WINAPI d3dx9_line_GetDevice(struct ID3DXLine *iface, struct IDirect3DDevice9 **device)
86 struct d3dx9_line *line = impl_from_ID3DXLine(iface);
88 TRACE("iface %p, device %p.\n", iface, line);
90 if (!device)
91 return D3DERR_INVALIDCALL;
93 *device = line->device;
94 IDirect3DDevice9_AddRef(line->device);
96 return D3D_OK;
99 static HRESULT WINAPI d3dx9_line_Begin(ID3DXLine *iface)
101 struct d3dx9_line *line = impl_from_ID3DXLine(iface);
102 D3DXMATRIX identity, projection;
103 D3DVIEWPORT9 vp;
105 TRACE("iface %p.\n", iface);
107 if (line->state)
108 return D3DERR_INVALIDCALL;
110 if (FAILED(IDirect3DDevice9_CreateStateBlock(line->device, D3DSBT_ALL, &line->state)))
111 return D3DXERR_INVALIDDATA;
113 if (FAILED(IDirect3DDevice9_GetViewport(line->device, &vp)))
114 goto failed;
116 D3DXMatrixIdentity(&identity);
117 D3DXMatrixOrthoOffCenterLH(&projection, 0.0, (FLOAT)vp.Width, (FLOAT)vp.Height, 0.0, 0.0, 1.0);
119 if (FAILED(IDirect3DDevice9_SetTransform(line->device, D3DTS_WORLD, &identity)))
120 goto failed;
121 if (FAILED(IDirect3DDevice9_SetTransform(line->device, D3DTS_VIEW, &identity)))
122 goto failed;
123 if (FAILED(IDirect3DDevice9_SetTransform(line->device, D3DTS_PROJECTION, &projection)))
124 goto failed;
126 if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_LIGHTING, FALSE)))
127 goto failed;
128 if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_FOGENABLE, FALSE)))
129 goto failed;
130 if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_SHADEMODE, D3DSHADE_FLAT)))
131 goto failed;
132 if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_ALPHABLENDENABLE, TRUE)))
133 goto failed;
134 if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA)))
135 goto failed;
136 if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA)))
137 goto failed;
139 return D3D_OK;
141 failed:
142 IDirect3DStateBlock9_Apply(line->state);
143 IDirect3DStateBlock9_Release(line->state);
144 line->state = NULL;
145 return D3DXERR_INVALIDDATA;
148 static HRESULT WINAPI d3dx9_line_Draw(ID3DXLine *iface, const D3DXVECTOR2 *vertex_list,
149 DWORD vertex_list_count, D3DCOLOR color)
151 FIXME("iface %p, vertex_list %p, vertex_list_count %lu, color 0x%08lx stub!\n",
152 iface, vertex_list, vertex_list_count, color);
154 return E_NOTIMPL;
157 static HRESULT WINAPI d3dx9_line_DrawTransform(ID3DXLine *iface, const D3DXVECTOR3 *vertex_list,
158 DWORD vertex_list_count, const D3DXMATRIX *transform, D3DCOLOR color)
160 FIXME("iface %p, vertex_list %p, vertex_list_count %lu, transform %p, color 0x%08lx stub!\n",
161 iface, vertex_list, vertex_list_count, transform, color);
163 return E_NOTIMPL;
166 static HRESULT WINAPI d3dx9_line_SetPattern(ID3DXLine *iface, DWORD pattern)
168 FIXME("iface %p, pattern 0x%08lx stub!\n", iface, pattern);
170 return E_NOTIMPL;
173 static DWORD WINAPI d3dx9_line_GetPattern(ID3DXLine *iface)
175 FIXME("iface %p stub!\n", iface);
177 return 0xffffffff;
180 static HRESULT WINAPI d3dx9_line_SetPatternScale(ID3DXLine *iface, float scale)
182 FIXME("iface %p, scale %.8e stub!\n", iface, scale);
184 return E_NOTIMPL;
187 static float WINAPI d3dx9_line_GetPatternScale(ID3DXLine *iface)
189 FIXME("iface %p stub!\n", iface);
191 return 1.0f;
194 static HRESULT WINAPI d3dx9_line_SetWidth(ID3DXLine *iface, float width)
196 struct d3dx9_line *line = impl_from_ID3DXLine(iface);
198 TRACE("iface %p, width %.8e.\n", iface, width);
200 if (width <= 0.0f)
201 return D3DERR_INVALIDCALL;
203 line->width = width;
205 return D3D_OK;
208 static float WINAPI d3dx9_line_GetWidth(ID3DXLine *iface)
210 struct d3dx9_line *line = impl_from_ID3DXLine(iface);
212 TRACE("iface %p.\n", iface);
214 return line->width;
217 static HRESULT WINAPI d3dx9_line_SetAntialias(ID3DXLine *iface, BOOL antialias)
219 FIXME("iface %p, antialias %#x stub!\n", iface, antialias);
221 return E_NOTIMPL;
224 static BOOL WINAPI d3dx9_line_GetAntialias(ID3DXLine *iface)
226 FIXME("iface %p stub!\n", iface);
228 return FALSE;
231 static HRESULT WINAPI d3dx9_line_SetGLLines(ID3DXLine *iface, BOOL gl_lines)
233 FIXME("iface %p, gl_lines %#x stub!\n", iface, gl_lines);
235 return E_NOTIMPL;
238 static BOOL WINAPI d3dx9_line_GetGLLines(ID3DXLine *iface)
240 FIXME("iface %p stub!\n", iface);
242 return FALSE;
245 static HRESULT WINAPI d3dx9_line_End(ID3DXLine *iface)
247 struct d3dx9_line *line = impl_from_ID3DXLine(iface);
249 HRESULT hr;
251 TRACE("iface %p.\n", iface);
253 if (!line->state)
254 return D3DERR_INVALIDCALL;
256 hr = IDirect3DStateBlock9_Apply(line->state);
257 IDirect3DStateBlock9_Release(line->state);
258 line->state = NULL;
260 if (FAILED(hr))
261 return D3DXERR_INVALIDDATA;
263 return D3D_OK;
266 static HRESULT WINAPI d3dx9_line_OnLostDevice(ID3DXLine *iface)
268 FIXME("iface %p stub!\n", iface);
270 return E_NOTIMPL;
272 static HRESULT WINAPI d3dx9_line_OnResetDevice(ID3DXLine *iface)
274 FIXME("iface %p stub!\n", iface);
276 return S_OK;
279 static const struct ID3DXLineVtbl d3dx9_line_vtbl =
281 d3dx9_line_QueryInterface,
282 d3dx9_line_AddRef,
283 d3dx9_line_Release,
284 d3dx9_line_GetDevice,
285 d3dx9_line_Begin,
286 d3dx9_line_Draw,
287 d3dx9_line_DrawTransform,
288 d3dx9_line_SetPattern,
289 d3dx9_line_GetPattern,
290 d3dx9_line_SetPatternScale,
291 d3dx9_line_GetPatternScale,
292 d3dx9_line_SetWidth,
293 d3dx9_line_GetWidth,
294 d3dx9_line_SetAntialias,
295 d3dx9_line_GetAntialias,
296 d3dx9_line_SetGLLines,
297 d3dx9_line_GetGLLines,
298 d3dx9_line_End,
299 d3dx9_line_OnLostDevice,
300 d3dx9_line_OnResetDevice,
303 HRESULT WINAPI D3DXCreateLine(struct IDirect3DDevice9 *device, struct ID3DXLine **line)
305 struct d3dx9_line *object;
307 TRACE("device %p, line %p.\n", device, line);
309 if (!device || !line)
310 return D3DERR_INVALIDCALL;
312 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
313 return E_OUTOFMEMORY;
315 object->ID3DXLine_iface.lpVtbl = &d3dx9_line_vtbl;
316 object->ref = 1;
317 object->device = device;
318 IDirect3DDevice9_AddRef(device);
319 object->width = 1.0f;
321 *line = &object->ID3DXLine_iface;
323 return D3D_OK;