Commit d0fd93ef authored by Tony Wasserka's avatar Tony Wasserka Committed by Alexandre Julliard

d3dx9: Implement D3DXCreateSprite.

parent 5ddcedff
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "d3dx9.h" #include "d3dx9.h"
/* ID3DXFont */
typedef struct ID3DXFontImpl typedef struct ID3DXFontImpl
{ {
/* IUnknown fields */ /* IUnknown fields */
...@@ -36,6 +37,17 @@ typedef struct ID3DXFontImpl ...@@ -36,6 +37,17 @@ typedef struct ID3DXFontImpl
/* ID3DXFont fields */ /* ID3DXFont fields */
} ID3DXFontImpl; } ID3DXFontImpl;
/*ID3DXSprite */
typedef struct _SPRITE {
LPDIRECT3DTEXTURE9 texture;
UINT texw, texh;
RECT rect;
D3DXVECTOR3 center;
D3DXVECTOR3 pos;
D3DCOLOR color;
} SPRITE;
typedef struct ID3DXSpriteImpl typedef struct ID3DXSpriteImpl
{ {
/* IUnknown fields */ /* IUnknown fields */
...@@ -43,6 +55,20 @@ typedef struct ID3DXSpriteImpl ...@@ -43,6 +55,20 @@ typedef struct ID3DXSpriteImpl
LONG ref; LONG ref;
/* ID3DXSprite fields */ /* ID3DXSprite fields */
IDirect3DDevice9 *device;
IDirect3DVertexDeclaration9 *vdecl;
IDirect3DStateBlock9 *stateblock;
D3DXMATRIX transform;
D3DXMATRIX view;
DWORD flags;
/* Store the relevant caps to prevent multiple GetDeviceCaps calls */
DWORD texfilter_caps;
DWORD maxanisotropy;
DWORD alphacmp_caps;
SPRITE *sprites;
int sprite_count;
} ID3DXSpriteImpl; } ID3DXSpriteImpl;
......
...@@ -51,6 +51,9 @@ static ULONG WINAPI ID3DXSpriteImpl_Release(LPD3DXSPRITE iface) ...@@ -51,6 +51,9 @@ static ULONG WINAPI ID3DXSpriteImpl_Release(LPD3DXSPRITE iface)
TRACE("(%p): ReleaseRef to %d\n", This, ref); TRACE("(%p): ReleaseRef to %d\n", This, ref);
if(ref==0) { if(ref==0) {
if(This->stateblock) IDirect3DStateBlock9_Release(This->stateblock);
if(This->vdecl) IDirect3DVertexDeclaration9_Release(This->vdecl);
if(This->device) IDirect3DDevice9_Release(This->device);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
...@@ -157,8 +160,16 @@ static const ID3DXSpriteVtbl D3DXSprite_Vtbl = ...@@ -157,8 +160,16 @@ static const ID3DXSpriteVtbl D3DXSprite_Vtbl =
HRESULT WINAPI D3DXCreateSprite(LPDIRECT3DDEVICE9 device, LPD3DXSPRITE *sprite) HRESULT WINAPI D3DXCreateSprite(LPDIRECT3DDEVICE9 device, LPD3DXSPRITE *sprite)
{ {
ID3DXSpriteImpl *object; ID3DXSpriteImpl *object;
D3DCAPS9 caps;
static const D3DVERTEXELEMENT9 elements[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
{ 0, 16, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
D3DDECL_END()
};
FIXME("stub\n"); TRACE("(void): relay\n");
if(device==NULL || sprite==NULL) return D3DERR_INVALIDCALL; if(device==NULL || sprite==NULL) return D3DERR_INVALIDCALL;
...@@ -169,6 +180,24 @@ HRESULT WINAPI D3DXCreateSprite(LPDIRECT3DDEVICE9 device, LPD3DXSPRITE *sprite) ...@@ -169,6 +180,24 @@ HRESULT WINAPI D3DXCreateSprite(LPDIRECT3DDEVICE9 device, LPD3DXSPRITE *sprite)
} }
object->lpVtbl=&D3DXSprite_Vtbl; object->lpVtbl=&D3DXSprite_Vtbl;
object->ref=1; object->ref=1;
object->device=device;
IUnknown_AddRef(device);
IDirect3DDevice9_CreateVertexDeclaration(object->device, elements, &object->vdecl);
object->stateblock=NULL;
D3DXMatrixIdentity(&object->transform);
D3DXMatrixIdentity(&object->view);
object->flags=0;
IDirect3DDevice9_GetDeviceCaps(device, &caps);
object->texfilter_caps=caps.TextureFilterCaps;
object->maxanisotropy=caps.MaxAnisotropy;
object->alphacmp_caps=caps.AlphaCmpCaps;
object->sprites=NULL;
object->sprite_count=0;
*sprite=(ID3DXSprite*)object; *sprite=(ID3DXSprite*)object;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment