From ae695bdfaaea2b114938ff92210a14f5748f7da7 Mon Sep 17 00:00:00 2001 From: Owen Rudge Date: Mon, 30 Aug 2010 11:57:42 -0500 Subject: [PATCH] d3dx9: Implement missing D3DXCreateTextureFromFile functions. --- dlls/d3dx9_36/d3dx9_36.spec | 10 +++--- dlls/d3dx9_36/texture.c | 64 +++++++++++++++++++++++++++++++++++-- 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/dlls/d3dx9_36/d3dx9_36.spec b/dlls/d3dx9_36/d3dx9_36.spec index 691f2ec50d3..c6c57fa5e30 100644 --- a/dlls/d3dx9_36/d3dx9_36.spec +++ b/dlls/d3dx9_36/d3dx9_36.spec @@ -93,12 +93,12 @@ @ stub D3DXCreateTextA @ stub D3DXCreateTextW @ stdcall D3DXCreateTexture(ptr long long long long long long ptr) -@ stdcall D3DXCreateTextureFromFileA(ptr ptr ptr) -@ stub D3DXCreateTextureFromFileExA -@ stdcall D3DXCreateTextureFromFileExW(ptr ptr long long long long long long long long long ptr ptr ptr) -@ stub D3DXCreateTextureFromFileInMemory +@ stdcall D3DXCreateTextureFromFileA(ptr str ptr) +@ stdcall D3DXCreateTextureFromFileExA(ptr str long long long long long long long long long ptr ptr ptr) +@ stdcall D3DXCreateTextureFromFileExW(ptr wstr long long long long long long long long long ptr ptr ptr) +@ stdcall D3DXCreateTextureFromFileInMemory(ptr ptr long ptr) @ stdcall D3DXCreateTextureFromFileInMemoryEx(ptr ptr long long long long long long long long long long ptr ptr ptr) -@ stub D3DXCreateTextureFromFileW +@ stdcall D3DXCreateTextureFromFileW(ptr wstr ptr) @ stub D3DXCreateTextureFromResourceA @ stub D3DXCreateTextureFromResourceExA @ stub D3DXCreateTextureFromResourceExW diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c index 8895a8fb8ee..4c4bc918ae8 100644 --- a/dlls/d3dx9_36/texture.c +++ b/dlls/d3dx9_36/texture.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "wine/unicode.h" #include "wine/debug.h" #include "d3dx9_36_private.h" @@ -289,6 +290,17 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(LPDIRECT3DDEVICE9 device, return E_NOTIMPL; } +HRESULT WINAPI D3DXCreateTextureFromFileInMemory(LPDIRECT3DDEVICE9 device, + LPCVOID srcdata, + UINT srcdatasize, + LPDIRECT3DTEXTURE9 *texture) +{ + TRACE("(%p, %p, %d, %p)\n", device, srcdata, srcdatasize, texture); + + return D3DXCreateTextureFromFileInMemoryEx(device, srcdata, srcdatasize, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, + D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, texture); +} + HRESULT WINAPI D3DXCreateTextureFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile, UINT width, @@ -326,11 +338,59 @@ HRESULT WINAPI D3DXCreateTextureFromFileExW(LPDIRECT3DDEVICE9 device, return hr; } +HRESULT WINAPI D3DXCreateTextureFromFileExA(LPDIRECT3DDEVICE9 device, + LPCSTR srcfile, + UINT width, + UINT height, + UINT miplevels, + DWORD usage, + D3DFORMAT format, + D3DPOOL pool, + DWORD filter, + DWORD mipfilter, + D3DCOLOR colorkey, + D3DXIMAGE_INFO *srcinfo, + PALETTEENTRY *palette, + LPDIRECT3DTEXTURE9 *texture) +{ + LPWSTR widename; + HRESULT hr; + DWORD len; + + TRACE("(%p, %p, %u, %u, %u, %x, %x, %x, %u, %u, %x, %p, %p, %p): relay\n", device, debugstr_a(srcfile), width, + height, miplevels, usage, format, pool, filter, mipfilter, colorkey, srcinfo, palette, texture); + + if (!device || !srcfile || !texture) + return D3DERR_INVALIDCALL; + + len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0); + widename = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, srcfile, -1, widename, len); + + hr = D3DXCreateTextureFromFileExW(device, widename, width, height, miplevels, + usage, format, pool, filter, mipfilter, + colorkey, srcinfo, palette, texture); + + HeapFree(GetProcessHeap(), 0, widename); + return hr; +} + HRESULT WINAPI D3DXCreateTextureFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile, LPDIRECT3DTEXTURE9 *texture) { - FIXME("(%p, %s, %p): stub\n", device, debugstr_a(srcfile), texture); + TRACE("(%p, %s, %p)\n", device, debugstr_a(srcfile), texture); - return E_NOTIMPL; + return D3DXCreateTextureFromFileExA(device, srcfile, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, + D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, texture); +} + +HRESULT WINAPI D3DXCreateTextureFromFileW(LPDIRECT3DDEVICE9 device, + LPCWSTR srcfile, + LPDIRECT3DTEXTURE9 *texture) +{ + TRACE("(%p, %s, %p)\n", device, debugstr_w(srcfile), texture); + + return D3DXCreateTextureFromFileExW(device, srcfile, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, + D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, texture); }