2010-04-02 08:54:42 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Christian Costa
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-03-15 04:03:22 +01:00
|
|
|
|
|
|
|
#include "d3dx9_private.h"
|
2010-04-02 08:54:42 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
struct d3dx9_line
|
|
|
|
{
|
2010-12-20 11:35:15 +01:00
|
|
|
ID3DXLine ID3DXLine_iface;
|
2010-04-02 08:54:42 +02:00
|
|
|
LONG ref;
|
2011-06-16 22:19:49 +02:00
|
|
|
|
|
|
|
IDirect3DDevice9 *device;
|
2011-06-30 00:08:20 +02:00
|
|
|
IDirect3DStateBlock9 *state;
|
2021-08-10 10:54:05 +02:00
|
|
|
float width;
|
2013-09-24 09:48:47 +02:00
|
|
|
};
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static inline struct d3dx9_line *impl_from_ID3DXLine(ID3DXLine *iface)
|
2010-12-20 11:35:15 +01:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d3dx9_line, ID3DXLine_iface);
|
2010-12-20 11:35:15 +01:00
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static HRESULT WINAPI d3dx9_line_QueryInterface(ID3DXLine *iface, REFIID riid, void **out)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-04 08:56:46 +02:00
|
|
|
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_ID3DXLine)
|
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
|
|
|
ID3DXLine_AddRef(iface);
|
2013-09-04 08:56:46 +02:00
|
|
|
*out = iface;
|
2010-04-02 08:54:42 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
*out = NULL;
|
2010-04-02 08:54:42 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static ULONG WINAPI d3dx9_line_AddRef(ID3DXLine *iface)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
struct d3dx9_line *line = impl_from_ID3DXLine(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&line->ref);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", line, refcount);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
return refcount;
|
2010-04-02 08:54:42 +02:00
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static ULONG WINAPI d3dx9_line_Release(ID3DXLine *iface)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
struct d3dx9_line *line = impl_from_ID3DXLine(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&line->ref);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", line, refcount);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
if (!refcount)
|
2011-06-16 22:19:49 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
IDirect3DDevice9_Release(line->device);
|
|
|
|
HeapFree(GetProcessHeap(), 0, line);
|
2011-06-16 22:19:49 +02:00
|
|
|
}
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
return refcount;
|
2010-04-02 08:54:42 +02:00
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static HRESULT WINAPI d3dx9_line_GetDevice(struct ID3DXLine *iface, struct IDirect3DDevice9 **device)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
struct d3dx9_line *line = impl_from_ID3DXLine(iface);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
TRACE("iface %p, device %p.\n", iface, line);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
if (!device)
|
|
|
|
return D3DERR_INVALIDCALL;
|
2011-06-16 22:19:49 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
*device = line->device;
|
|
|
|
IDirect3DDevice9_AddRef(line->device);
|
2011-06-16 22:19:49 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
2010-04-02 08:54:42 +02:00
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static HRESULT WINAPI d3dx9_line_Begin(ID3DXLine *iface)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
struct d3dx9_line *line = impl_from_ID3DXLine(iface);
|
2011-06-30 00:08:20 +02:00
|
|
|
D3DXMATRIX identity, projection;
|
|
|
|
D3DVIEWPORT9 vp;
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
2011-06-30 00:08:20 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
if (line->state)
|
2011-06-30 00:08:20 +02:00
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
if (FAILED(IDirect3DDevice9_CreateStateBlock(line->device, D3DSBT_ALL, &line->state)))
|
|
|
|
return D3DXERR_INVALIDDATA;
|
2011-06-30 00:08:20 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
if (FAILED(IDirect3DDevice9_GetViewport(line->device, &vp)))
|
|
|
|
goto failed;
|
2011-06-30 00:08:20 +02:00
|
|
|
|
|
|
|
D3DXMatrixIdentity(&identity);
|
2014-01-03 14:17:20 +01:00
|
|
|
D3DXMatrixOrthoOffCenterLH(&projection, 0.0, (FLOAT)vp.Width, (FLOAT)vp.Height, 0.0, 0.0, 1.0);
|
2013-09-24 09:48:47 +02:00
|
|
|
|
|
|
|
if (FAILED(IDirect3DDevice9_SetTransform(line->device, D3DTS_WORLD, &identity)))
|
|
|
|
goto failed;
|
|
|
|
if (FAILED(IDirect3DDevice9_SetTransform(line->device, D3DTS_VIEW, &identity)))
|
|
|
|
goto failed;
|
|
|
|
if (FAILED(IDirect3DDevice9_SetTransform(line->device, D3DTS_PROJECTION, &projection)))
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_LIGHTING, FALSE)))
|
|
|
|
goto failed;
|
|
|
|
if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_FOGENABLE, FALSE)))
|
|
|
|
goto failed;
|
|
|
|
if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_SHADEMODE, D3DSHADE_FLAT)))
|
|
|
|
goto failed;
|
|
|
|
if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_ALPHABLENDENABLE, TRUE)))
|
|
|
|
goto failed;
|
|
|
|
if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA)))
|
|
|
|
goto failed;
|
|
|
|
if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA)))
|
|
|
|
goto failed;
|
2011-06-30 00:08:20 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
2013-09-24 09:48:47 +02:00
|
|
|
|
2011-06-30 00:08:20 +02:00
|
|
|
failed:
|
2013-09-24 09:48:47 +02:00
|
|
|
IDirect3DStateBlock9_Apply(line->state);
|
|
|
|
IDirect3DStateBlock9_Release(line->state);
|
|
|
|
line->state = NULL;
|
2011-06-30 00:08:20 +02:00
|
|
|
return D3DXERR_INVALIDDATA;
|
2010-04-02 08:54:42 +02:00
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static HRESULT WINAPI d3dx9_line_Draw(ID3DXLine *iface, const D3DXVECTOR2 *vertex_list,
|
2013-09-20 10:41:46 +02:00
|
|
|
DWORD vertex_list_count, D3DCOLOR color)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-20 10:41:46 +02:00
|
|
|
FIXME("iface %p, vertex_list %p, vertex_list_count %u, color 0x%08x stub!\n",
|
|
|
|
iface, vertex_list, vertex_list_count, color);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static HRESULT WINAPI d3dx9_line_DrawTransform(ID3DXLine *iface, const D3DXVECTOR3 *vertex_list,
|
2013-09-20 10:41:46 +02:00
|
|
|
DWORD vertex_list_count, const D3DXMATRIX *transform, D3DCOLOR color)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-20 10:41:46 +02:00
|
|
|
FIXME("iface %p, vertex_list %p, vertex_list_count %u, transform %p, color 0x%08x stub!\n",
|
|
|
|
iface, vertex_list, vertex_list_count, transform, color);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static HRESULT WINAPI d3dx9_line_SetPattern(ID3DXLine *iface, DWORD pattern)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
FIXME("iface %p, pattern 0x%08x stub!\n", iface, pattern);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static DWORD WINAPI d3dx9_line_GetPattern(ID3DXLine *iface)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
FIXME("iface %p stub!\n", iface);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
return 0xffffffff;
|
2010-04-02 08:54:42 +02:00
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static HRESULT WINAPI d3dx9_line_SetPatternScale(ID3DXLine *iface, float scale)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
FIXME("iface %p, scale %.8e stub!\n", iface, scale);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static float WINAPI d3dx9_line_GetPatternScale(ID3DXLine *iface)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
FIXME("iface %p stub!\n", iface);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
|
|
|
return 1.0f;
|
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static HRESULT WINAPI d3dx9_line_SetWidth(ID3DXLine *iface, float width)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2021-08-10 10:54:05 +02:00
|
|
|
struct d3dx9_line *line = impl_from_ID3DXLine(iface);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2021-08-10 10:54:05 +02:00
|
|
|
TRACE("iface %p, width %.8e.\n", iface, width);
|
|
|
|
|
|
|
|
if (width <= 0.0f)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
|
|
|
line->width = width;
|
|
|
|
|
|
|
|
return D3D_OK;
|
2010-04-02 08:54:42 +02:00
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static float WINAPI d3dx9_line_GetWidth(ID3DXLine *iface)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2021-08-10 10:54:05 +02:00
|
|
|
struct d3dx9_line *line = impl_from_ID3DXLine(iface);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2021-08-10 10:54:05 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return line->width;
|
2010-04-02 08:54:42 +02:00
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static HRESULT WINAPI d3dx9_line_SetAntialias(ID3DXLine *iface, BOOL antialias)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
FIXME("iface %p, antialias %#x stub!\n", iface, antialias);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static BOOL WINAPI d3dx9_line_GetAntialias(ID3DXLine *iface)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
FIXME("iface %p stub!\n", iface);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static HRESULT WINAPI d3dx9_line_SetGLLines(ID3DXLine *iface, BOOL gl_lines)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
FIXME("iface %p, gl_lines %#x stub!\n", iface, gl_lines);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static BOOL WINAPI d3dx9_line_GetGLLines(ID3DXLine *iface)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
FIXME("iface %p stub!\n", iface);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static HRESULT WINAPI d3dx9_line_End(ID3DXLine *iface)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
struct d3dx9_line *line = impl_from_ID3DXLine(iface);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2011-06-30 00:08:20 +02:00
|
|
|
HRESULT hr;
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
2011-06-30 00:08:20 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
if (!line->state)
|
2011-06-30 00:08:20 +02:00
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
hr = IDirect3DStateBlock9_Apply(line->state);
|
|
|
|
IDirect3DStateBlock9_Release(line->state);
|
|
|
|
line->state = NULL;
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
return D3DXERR_INVALIDDATA;
|
2011-06-30 00:08:20 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
return D3D_OK;
|
2010-04-02 08:54:42 +02:00
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static HRESULT WINAPI d3dx9_line_OnLostDevice(ID3DXLine *iface)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
FIXME("iface %p stub!\n", iface);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2013-09-24 09:48:47 +02:00
|
|
|
static HRESULT WINAPI d3dx9_line_OnResetDevice(ID3DXLine *iface)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
FIXME("iface %p stub!\n", iface);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2020-01-08 04:41:42 +01:00
|
|
|
return S_OK;
|
2010-04-02 08:54:42 +02:00
|
|
|
}
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
static const struct ID3DXLineVtbl d3dx9_line_vtbl =
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
d3dx9_line_QueryInterface,
|
|
|
|
d3dx9_line_AddRef,
|
|
|
|
d3dx9_line_Release,
|
|
|
|
d3dx9_line_GetDevice,
|
|
|
|
d3dx9_line_Begin,
|
|
|
|
d3dx9_line_Draw,
|
|
|
|
d3dx9_line_DrawTransform,
|
|
|
|
d3dx9_line_SetPattern,
|
|
|
|
d3dx9_line_GetPattern,
|
|
|
|
d3dx9_line_SetPatternScale,
|
|
|
|
d3dx9_line_GetPatternScale,
|
|
|
|
d3dx9_line_SetWidth,
|
|
|
|
d3dx9_line_GetWidth,
|
|
|
|
d3dx9_line_SetAntialias,
|
|
|
|
d3dx9_line_GetAntialias,
|
|
|
|
d3dx9_line_SetGLLines,
|
|
|
|
d3dx9_line_GetGLLines,
|
|
|
|
d3dx9_line_End,
|
|
|
|
d3dx9_line_OnLostDevice,
|
|
|
|
d3dx9_line_OnResetDevice,
|
2010-04-02 08:54:42 +02:00
|
|
|
};
|
|
|
|
|
2012-10-28 20:54:52 +01:00
|
|
|
HRESULT WINAPI D3DXCreateLine(struct IDirect3DDevice9 *device, struct ID3DXLine **line)
|
2010-04-02 08:54:42 +02:00
|
|
|
{
|
2013-09-24 09:48:47 +02:00
|
|
|
struct d3dx9_line *object;
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
TRACE("device %p, line %p.\n", device, line);
|
2010-04-02 08:54:42 +02:00
|
|
|
|
|
|
|
if (!device || !line)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
2010-04-02 08:54:42 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2013-09-24 09:48:47 +02:00
|
|
|
object->ID3DXLine_iface.lpVtbl = &d3dx9_line_vtbl;
|
2010-04-02 08:54:42 +02:00
|
|
|
object->ref = 1;
|
2011-06-16 22:19:49 +02:00
|
|
|
object->device = device;
|
|
|
|
IDirect3DDevice9_AddRef(device);
|
2021-08-10 10:54:05 +02:00
|
|
|
object->width = 1.0f;
|
2010-04-02 08:54:42 +02:00
|
|
|
|
2010-12-20 11:35:15 +01:00
|
|
|
*line = &object->ID3DXLine_iface;
|
2010-04-02 08:54:42 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|