2008-03-14 14:12:30 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 Tony Wasserka
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "d3dx9_36_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
|
|
|
|
|
2012-06-19 01:15:36 +02:00
|
|
|
struct d3dx_font
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2011-01-27 00:28:41 +01:00
|
|
|
ID3DXFont ID3DXFont_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
IDirect3DDevice9 *device;
|
|
|
|
D3DXFONT_DESCW desc;
|
|
|
|
|
|
|
|
HDC hdc;
|
|
|
|
HFONT hfont;
|
2012-06-19 01:15:36 +02:00
|
|
|
};
|
2011-01-27 00:28:41 +01:00
|
|
|
|
2012-06-19 01:15:36 +02:00
|
|
|
static inline struct d3dx_font *impl_from_ID3DXFont(ID3DXFont *iface)
|
2011-01-27 00:28:41 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d3dx_font, ID3DXFont_iface);
|
2011-01-27 00:28:41 +01:00
|
|
|
}
|
|
|
|
|
2012-04-10 22:06:22 +02:00
|
|
|
static HRESULT WINAPI ID3DXFontImpl_QueryInterface(ID3DXFont *iface, REFIID riid, void **out)
|
2011-01-27 00:28:41 +01:00
|
|
|
{
|
2012-04-10 22:06:22 +02:00
|
|
|
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
2008-03-14 14:12:30 +01:00
|
|
|
|
2012-04-10 22:06:22 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_ID3DXFont)
|
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
2008-03-14 14:12:30 +01:00
|
|
|
IUnknown_AddRef(iface);
|
2012-04-10 22:06:22 +02:00
|
|
|
*out = iface;
|
2008-03-14 14:12:30 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2012-04-10 22:06:22 +02:00
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
*out = NULL;
|
2008-03-14 14:12:30 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2011-01-27 00:28:41 +01:00
|
|
|
static ULONG WINAPI ID3DXFontImpl_AddRef(ID3DXFont *iface)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
struct d3dx_font *This = impl_from_ID3DXFont(iface);
|
2008-03-14 14:12:30 +01:00
|
|
|
ULONG ref=InterlockedIncrement(&This->ref);
|
2012-06-19 01:15:36 +02:00
|
|
|
TRACE("%p increasing refcount to %u\n", iface, ref);
|
2008-03-14 14:12:30 +01:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2011-01-27 00:28:41 +01:00
|
|
|
static ULONG WINAPI ID3DXFontImpl_Release(ID3DXFont *iface)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
struct d3dx_font *This = impl_from_ID3DXFont(iface);
|
2008-03-14 14:12:30 +01:00
|
|
|
ULONG ref=InterlockedDecrement(&This->ref);
|
2010-04-02 08:54:54 +02:00
|
|
|
|
2012-06-19 01:15:36 +02:00
|
|
|
TRACE("%p decreasing refcount to %u\n", iface, ref);
|
2008-03-14 14:12:30 +01:00
|
|
|
|
|
|
|
if(ref==0) {
|
2009-06-05 13:57:23 +02:00
|
|
|
DeleteObject(This->hfont);
|
2009-06-05 13:45:12 +02:00
|
|
|
DeleteDC(This->hdc);
|
2009-06-05 13:15:44 +02:00
|
|
|
IDirect3DDevice9_Release(This->device);
|
2008-03-14 14:12:30 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2012-06-19 01:15:36 +02:00
|
|
|
static HRESULT WINAPI ID3DXFontImpl_GetDevice(ID3DXFont *iface, IDirect3DDevice9 **device)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
struct d3dx_font *This = impl_from_ID3DXFont(iface);
|
2010-04-02 08:54:54 +02:00
|
|
|
|
2012-06-19 01:15:36 +02:00
|
|
|
TRACE("iface %p, device %p\n", iface, device);
|
2009-06-05 13:15:44 +02:00
|
|
|
|
|
|
|
if( !device ) return D3DERR_INVALIDCALL;
|
|
|
|
*device = This->device;
|
|
|
|
IDirect3DDevice9_AddRef(This->device);
|
|
|
|
|
2008-03-14 14:12:30 +01:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-27 00:28:41 +01:00
|
|
|
static HRESULT WINAPI ID3DXFontImpl_GetDescA(ID3DXFont *iface, D3DXFONT_DESCA *desc)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
struct d3dx_font *This = impl_from_ID3DXFont(iface);
|
2010-04-02 08:54:54 +02:00
|
|
|
|
2012-06-19 01:15:36 +02:00
|
|
|
TRACE("iface %p, desc %p\n", iface, desc);
|
2009-06-05 13:26:11 +02:00
|
|
|
|
|
|
|
if( !desc ) return D3DERR_INVALIDCALL;
|
|
|
|
memcpy(desc, &This->desc, FIELD_OFFSET(D3DXFONT_DESCA, FaceName));
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, This->desc.FaceName, -1, desc->FaceName, sizeof(desc->FaceName) / sizeof(CHAR), NULL, NULL);
|
|
|
|
|
2008-03-14 14:12:30 +01:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-27 00:28:41 +01:00
|
|
|
static HRESULT WINAPI ID3DXFontImpl_GetDescW(ID3DXFont *iface, D3DXFONT_DESCW *desc)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
struct d3dx_font *This = impl_from_ID3DXFont(iface);
|
2010-04-02 08:54:54 +02:00
|
|
|
|
2012-06-19 01:15:36 +02:00
|
|
|
TRACE("iface %p, desc %p\n", iface, desc);
|
2009-06-05 13:26:11 +02:00
|
|
|
|
|
|
|
if( !desc ) return D3DERR_INVALIDCALL;
|
|
|
|
*desc = This->desc;
|
|
|
|
|
2008-03-14 14:12:30 +01:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-27 00:28:41 +01:00
|
|
|
static BOOL WINAPI ID3DXFontImpl_GetTextMetricsA(ID3DXFont *iface, TEXTMETRICA *metrics)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
struct d3dx_font *This = impl_from_ID3DXFont(iface);
|
|
|
|
TRACE("iface %p, metrics %p\n", iface, metrics);
|
2009-06-05 13:57:23 +02:00
|
|
|
return GetTextMetricsA(This->hdc, metrics);
|
2008-03-14 14:12:30 +01:00
|
|
|
}
|
|
|
|
|
2011-01-27 00:28:41 +01:00
|
|
|
static BOOL WINAPI ID3DXFontImpl_GetTextMetricsW(ID3DXFont *iface, TEXTMETRICW *metrics)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
struct d3dx_font *This = impl_from_ID3DXFont(iface);
|
|
|
|
TRACE("iface %p, metrics %p\n", iface, metrics);
|
2009-06-05 13:57:23 +02:00
|
|
|
return GetTextMetricsW(This->hdc, metrics);
|
2008-03-14 14:12:30 +01:00
|
|
|
}
|
|
|
|
|
2011-01-27 00:28:41 +01:00
|
|
|
static HDC WINAPI ID3DXFontImpl_GetDC(ID3DXFont *iface)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
struct d3dx_font *This = impl_from_ID3DXFont(iface);
|
|
|
|
TRACE("iface %p\n", iface);
|
2009-06-05 13:45:12 +02:00
|
|
|
return This->hdc;
|
2008-03-14 14:12:30 +01:00
|
|
|
}
|
|
|
|
|
2011-01-27 00:28:41 +01:00
|
|
|
static HRESULT WINAPI ID3DXFontImpl_GetGlyphData(ID3DXFont *iface, UINT glyph,
|
2012-06-01 17:22:50 +02:00
|
|
|
IDirect3DTexture9 **texture, RECT *blackbox, POINT *cellinc)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-10-28 22:59:58 +01:00
|
|
|
FIXME("iface %p, glyph %#x, texture %p, blackbox %s, cellinc %s stub!\n",
|
2012-06-01 17:22:50 +02:00
|
|
|
iface, glyph, texture, wine_dbgstr_rect(blackbox), wine_dbgstr_point(cellinc));
|
2012-06-19 01:15:36 +02:00
|
|
|
return E_NOTIMPL;
|
2008-03-14 14:12:30 +01:00
|
|
|
}
|
|
|
|
|
2011-01-27 00:28:41 +01:00
|
|
|
static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(ID3DXFont *iface, UINT first, UINT last)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
FIXME("iface %p, first %u, last %u stub!\n", iface, first, last);
|
|
|
|
return E_NOTIMPL;
|
2008-03-14 14:12:30 +01:00
|
|
|
}
|
|
|
|
|
2011-01-27 00:28:41 +01:00
|
|
|
static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first, UINT last)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
FIXME("iface %p, first %u, last %u stub!\n", iface, first, last);
|
|
|
|
return E_NOTIMPL;
|
2008-03-14 14:12:30 +01:00
|
|
|
}
|
|
|
|
|
2012-06-19 01:15:36 +02:00
|
|
|
static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(ID3DXFont *iface, const char *string, INT count)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
FIXME("iface %p, string %s, count %d stub!\n", iface, debugstr_a(string), count);
|
|
|
|
return E_NOTIMPL;
|
2008-03-14 14:12:30 +01:00
|
|
|
}
|
|
|
|
|
2012-06-19 01:15:36 +02:00
|
|
|
static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR *string, INT count)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
FIXME("iface %p, string %s, count %d stub!\n", iface, debugstr_w(string), count);
|
|
|
|
return E_NOTIMPL;
|
2008-03-14 14:12:30 +01:00
|
|
|
}
|
|
|
|
|
2012-06-01 17:22:50 +02:00
|
|
|
static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite,
|
|
|
|
const char *string, INT count, RECT *rect, DWORD format, D3DCOLOR color)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-01 17:22:50 +02:00
|
|
|
FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n",
|
|
|
|
iface, sprite, debugstr_a(string), count, wine_dbgstr_rect(rect), format, color);
|
2008-03-14 14:12:30 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-06-01 17:22:50 +02:00
|
|
|
static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
|
|
|
|
const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR color)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-01 17:22:50 +02:00
|
|
|
FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n",
|
|
|
|
iface, sprite, debugstr_w(string), count, wine_dbgstr_rect(rect), format, color);
|
2008-03-14 14:12:30 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-01-27 00:28:41 +01:00
|
|
|
static HRESULT WINAPI ID3DXFontImpl_OnLostDevice(ID3DXFont *iface)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
FIXME("iface %p stub!\n", iface);
|
2008-03-14 14:12:30 +01:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-27 00:28:41 +01:00
|
|
|
static HRESULT WINAPI ID3DXFontImpl_OnResetDevice(ID3DXFont *iface)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2012-06-19 01:15:36 +02:00
|
|
|
FIXME("iface %p stub\n", iface);
|
2008-03-14 14:12:30 +01:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ID3DXFontVtbl D3DXFont_Vtbl =
|
|
|
|
{
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
ID3DXFontImpl_QueryInterface,
|
|
|
|
ID3DXFontImpl_AddRef,
|
|
|
|
ID3DXFontImpl_Release,
|
|
|
|
/*** ID3DXFont methods ***/
|
|
|
|
ID3DXFontImpl_GetDevice,
|
|
|
|
ID3DXFontImpl_GetDescA,
|
|
|
|
ID3DXFontImpl_GetDescW,
|
|
|
|
ID3DXFontImpl_GetTextMetricsA,
|
|
|
|
ID3DXFontImpl_GetTextMetricsW,
|
|
|
|
ID3DXFontImpl_GetDC,
|
|
|
|
ID3DXFontImpl_GetGlyphData,
|
|
|
|
ID3DXFontImpl_PreloadCharacters,
|
|
|
|
ID3DXFontImpl_PreloadGlyphs,
|
|
|
|
ID3DXFontImpl_PreloadTextA,
|
|
|
|
ID3DXFontImpl_PreloadTextW,
|
|
|
|
ID3DXFontImpl_DrawTextA,
|
|
|
|
ID3DXFontImpl_DrawTextW,
|
|
|
|
ID3DXFontImpl_OnLostDevice,
|
|
|
|
ID3DXFontImpl_OnResetDevice
|
|
|
|
};
|
|
|
|
|
2012-10-28 20:54:52 +01:00
|
|
|
HRESULT WINAPI D3DXCreateFontA(struct IDirect3DDevice9 *device, INT height, UINT width,
|
|
|
|
UINT weight, UINT miplevels, BOOL italic, DWORD charset, DWORD precision, DWORD quality,
|
|
|
|
DWORD pitchandfamily, const char *facename, struct ID3DXFont **font)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
|
|
|
D3DXFONT_DESCA desc;
|
|
|
|
|
2009-06-05 13:06:25 +02:00
|
|
|
if( !device || !font ) return D3DERR_INVALIDCALL;
|
2008-03-14 14:12:30 +01:00
|
|
|
|
|
|
|
desc.Height=height;
|
|
|
|
desc.Width=width;
|
|
|
|
desc.Weight=weight;
|
|
|
|
desc.MipLevels=miplevels;
|
|
|
|
desc.Italic=italic;
|
|
|
|
desc.CharSet=charset;
|
|
|
|
desc.OutputPrecision=precision;
|
|
|
|
desc.Quality=quality;
|
|
|
|
desc.PitchAndFamily=pitchandfamily;
|
2009-06-05 13:06:25 +02:00
|
|
|
if(facename != NULL) lstrcpyA(desc.FaceName, facename);
|
|
|
|
else desc.FaceName[0] = '\0';
|
2008-03-14 14:12:30 +01:00
|
|
|
|
|
|
|
return D3DXCreateFontIndirectA(device, &desc, font);
|
|
|
|
}
|
|
|
|
|
2012-06-19 01:15:36 +02:00
|
|
|
HRESULT WINAPI D3DXCreateFontW(IDirect3DDevice9 *device, INT height, UINT width, UINT weight, UINT miplevels, BOOL italic, DWORD charset,
|
|
|
|
DWORD precision, DWORD quality, DWORD pitchandfamily, const WCHAR *facename, ID3DXFont **font)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
|
|
|
D3DXFONT_DESCW desc;
|
|
|
|
|
2009-06-05 13:06:25 +02:00
|
|
|
if( !device || !font ) return D3DERR_INVALIDCALL;
|
2008-03-14 14:12:30 +01:00
|
|
|
|
|
|
|
desc.Height=height;
|
|
|
|
desc.Width=width;
|
|
|
|
desc.Weight=weight;
|
|
|
|
desc.MipLevels=miplevels;
|
|
|
|
desc.Italic=italic;
|
|
|
|
desc.CharSet=charset;
|
|
|
|
desc.OutputPrecision=precision;
|
|
|
|
desc.Quality=quality;
|
|
|
|
desc.PitchAndFamily=pitchandfamily;
|
2009-06-05 13:06:25 +02:00
|
|
|
if(facename != NULL) strcpyW(desc.FaceName, facename);
|
|
|
|
else desc.FaceName[0] = '\0';
|
2008-03-14 14:12:30 +01:00
|
|
|
|
|
|
|
return D3DXCreateFontIndirectW(device, &desc, font);
|
|
|
|
}
|
|
|
|
|
2008-07-26 19:20:33 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* D3DXCreateFontIndirectA (D3DX9_36.@)
|
|
|
|
*/
|
2012-06-19 01:15:36 +02:00
|
|
|
HRESULT WINAPI D3DXCreateFontIndirectA(IDirect3DDevice9 *device, const D3DXFONT_DESCA *desc, ID3DXFont **font)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
|
|
|
D3DXFONT_DESCW widedesc;
|
|
|
|
|
2009-06-05 13:06:25 +02:00
|
|
|
if( !device || !desc || !font ) return D3DERR_INVALIDCALL;
|
2008-03-14 14:12:30 +01:00
|
|
|
|
|
|
|
/* Copy everything but the last structure member. This requires the
|
|
|
|
two D3DXFONT_DESC structures to be equal until the FaceName member */
|
|
|
|
memcpy(&widedesc, desc, FIELD_OFFSET(D3DXFONT_DESCA, FaceName));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, desc->FaceName, -1,
|
|
|
|
widedesc.FaceName, sizeof(widedesc.FaceName)/sizeof(WCHAR));
|
|
|
|
return D3DXCreateFontIndirectW(device, &widedesc, font);
|
|
|
|
}
|
|
|
|
|
2008-07-26 19:20:33 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* D3DXCreateFontIndirectW (D3DX9_36.@)
|
|
|
|
*/
|
2012-06-19 01:15:36 +02:00
|
|
|
HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_DESCW *desc, ID3DXFont **font)
|
2008-03-14 14:12:30 +01:00
|
|
|
{
|
2009-06-05 13:06:25 +02:00
|
|
|
D3DDEVICE_CREATION_PARAMETERS cpars;
|
|
|
|
D3DDISPLAYMODE mode;
|
2012-06-19 01:15:36 +02:00
|
|
|
struct d3dx_font *object;
|
2009-06-05 13:06:25 +02:00
|
|
|
IDirect3D9 *d3d;
|
|
|
|
HRESULT hr;
|
2010-04-02 08:54:54 +02:00
|
|
|
|
|
|
|
FIXME("(%p, %p, %p): stub\n", device, desc, font);
|
2008-03-14 14:12:30 +01:00
|
|
|
|
2009-06-05 13:06:25 +02:00
|
|
|
if( !device || !desc || !font ) return D3DERR_INVALIDCALL;
|
|
|
|
|
|
|
|
/* the device MUST support D3DFMT_A8R8G8B8 */
|
|
|
|
IDirect3DDevice9_GetDirect3D(device, &d3d);
|
|
|
|
IDirect3DDevice9_GetCreationParameters(device, &cpars);
|
|
|
|
IDirect3DDevice9_GetDisplayMode(device, 0, &mode);
|
|
|
|
hr = IDirect3D9_CheckDeviceFormat(d3d, cpars.AdapterOrdinal, cpars.DeviceType, mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8);
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
IDirect3D9_Release(d3d);
|
|
|
|
return D3DXERR_INVALIDDATA;
|
|
|
|
}
|
|
|
|
IDirect3D9_Release(d3d);
|
2008-03-14 14:12:30 +01:00
|
|
|
|
2012-06-19 01:15:36 +02:00
|
|
|
object = HeapAlloc(GetProcessHeap(), 0, sizeof(struct d3dx_font));
|
2008-03-14 14:12:30 +01:00
|
|
|
if(object==NULL) {
|
|
|
|
*font=NULL;
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2011-01-27 00:28:41 +01:00
|
|
|
object->ID3DXFont_iface.lpVtbl = &D3DXFont_Vtbl;
|
2008-03-14 14:12:30 +01:00
|
|
|
object->ref=1;
|
2009-06-05 13:15:44 +02:00
|
|
|
object->device=device;
|
2009-06-05 13:26:11 +02:00
|
|
|
object->desc=*desc;
|
2008-03-14 14:12:30 +01:00
|
|
|
|
2009-06-05 13:45:12 +02:00
|
|
|
object->hdc = CreateCompatibleDC(NULL);
|
|
|
|
if( !object->hdc ) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return D3DXERR_INVALIDDATA;
|
|
|
|
}
|
|
|
|
|
2009-06-05 13:57:23 +02:00
|
|
|
object->hfont = CreateFontW(desc->Height, desc->Width, 0, 0, desc->Weight, desc->Italic, FALSE, FALSE, desc->CharSet,
|
|
|
|
desc->OutputPrecision, CLIP_DEFAULT_PRECIS, desc->Quality, desc->PitchAndFamily, desc->FaceName);
|
|
|
|
if( !object->hfont ) {
|
|
|
|
DeleteDC(object->hdc);
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return D3DXERR_INVALIDDATA;
|
|
|
|
}
|
|
|
|
SelectObject(object->hdc, object->hfont);
|
|
|
|
|
2009-06-05 13:15:44 +02:00
|
|
|
IDirect3DDevice9_AddRef(device);
|
2011-01-27 00:28:41 +01:00
|
|
|
*font=&object->ID3DXFont_iface;
|
2008-03-14 14:12:30 +01:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|