d3dx9: Implement ID3DXSprite_Flush.

This commit is contained in:
Tony Wasserka 2008-11-07 17:01:27 +01:00 committed by Alexandre Julliard
parent 6fae43c0c8
commit 67dadeb7c8
1 changed files with 52 additions and 2 deletions

View File

@ -302,10 +302,60 @@ static HRESULT WINAPI ID3DXSpriteImpl_Draw(LPD3DXSPRITE iface, LPDIRECT3DTEXTURE
static HRESULT WINAPI ID3DXSpriteImpl_Flush(LPD3DXSPRITE iface)
{
ID3DXSpriteImpl *This=(ID3DXSpriteImpl*)iface;
SPRITEVERTEX *vertices;
int i;
FIXME("(%p): stub\n", This);
TRACE("(%p): relay\n", This);
if(!This->ready) return D3DERR_INVALIDCALL;
if(!This->sprite_count) return D3D_OK;
/* TODO: use of a vertex buffer here */
vertices=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SPRITEVERTEX)*4*This->sprite_count);
for(i=0;i<This->sprite_count;i++) {
float spritewidth=(float)This->sprites[i].rect.right-(float)This->sprites[i].rect.left;
float spriteheight=(float)This->sprites[i].rect.bottom-(float)This->sprites[i].rect.top;
vertices[4*i ].pos.x = This->sprites[i].pos.x - This->sprites[i].center.x;
vertices[4*i ].pos.y = This->sprites[i].pos.y - This->sprites[i].center.y;
vertices[4*i ].pos.z = This->sprites[i].pos.z - This->sprites[i].center.z;
vertices[4*i+1].pos.x = spritewidth + This->sprites[i].pos.x - This->sprites[i].center.x;
vertices[4*i+1].pos.y = This->sprites[i].pos.y - This->sprites[i].center.y;
vertices[4*i+1].pos.z = This->sprites[i].pos.z - This->sprites[i].center.z;
vertices[4*i+2].pos.x = spritewidth + This->sprites[i].pos.x - This->sprites[i].center.x;
vertices[4*i+2].pos.y = spriteheight + This->sprites[i].pos.y - This->sprites[i].center.y;
vertices[4*i+2].pos.z = This->sprites[i].pos.z - This->sprites[i].center.z;
vertices[4*i+3].pos.x = This->sprites[i].pos.x - This->sprites[i].center.x;
vertices[4*i+3].pos.y = spriteheight + This->sprites[i].pos.y - This->sprites[i].center.y;
vertices[4*i+3].pos.z = This->sprites[i].pos.z - This->sprites[i].center.z;
vertices[4*i ].col = This->sprites[i].color;
vertices[4*i+1].col = This->sprites[i].color;
vertices[4*i+2].col = This->sprites[i].color;
vertices[4*i+3].col = This->sprites[i].color;
vertices[4*i ].tex.x = (float)This->sprites[i].rect.left / (float)This->sprites[i].texw;
vertices[4*i ].tex.y = (float)This->sprites[i].rect.top / (float)This->sprites[i].texh;
vertices[4*i+1].tex.x = (float)This->sprites[i].rect.right / (float)This->sprites[i].texw;
vertices[4*i+1].tex.y = (float)This->sprites[i].rect.top / (float)This->sprites[i].texh;
vertices[4*i+2].tex.x = (float)This->sprites[i].rect.right / (float)This->sprites[i].texw;
vertices[4*i+2].tex.y = (float)This->sprites[i].rect.bottom / (float)This->sprites[i].texh;
vertices[4*i+3].tex.x = (float)This->sprites[i].rect.left / (float)This->sprites[i].texw;
vertices[4*i+3].tex.y = (float)This->sprites[i].rect.bottom / (float)This->sprites[i].texh;
}
D3DXVec3TransformCoordArray(&vertices[0].pos, sizeof(SPRITEVERTEX), &vertices[0].pos, sizeof(SPRITEVERTEX), &This->transform, 4*This->sprite_count);
D3DXVec3TransformCoordArray(&vertices[0].pos, sizeof(SPRITEVERTEX), &vertices[0].pos, sizeof(SPRITEVERTEX), &This->view, 4*This->sprite_count);
IDirect3DDevice9_SetVertexDeclaration(This->device, This->vdecl);
for(i=0;i<This->sprite_count;i++) {
if(!i)
IDirect3DDevice9_SetTexture(This->device, 0, (LPDIRECT3DBASETEXTURE9)(This->sprites[i].texture));
else if(This->sprites[i].texture!=This->sprites[i-1].texture)
IDirect3DDevice9_SetTexture(This->device, 0, (LPDIRECT3DBASETEXTURE9)(This->sprites[i].texture));
IDirect3DDevice9_DrawPrimitiveUP(This->device, D3DPT_TRIANGLEFAN, 2, vertices+4*i, sizeof(SPRITEVERTEX));
}
HeapFree(GetProcessHeap(), 0, vertices);
for(i=0;i<This->sprite_count;i++)
if(This->sprites[i].texture)
@ -315,7 +365,7 @@ static HRESULT WINAPI ID3DXSpriteImpl_Flush(LPD3DXSPRITE iface)
/* Flush may be called more than once, so we don't reset This->ready here */
return E_NOTIMPL;
return D3D_OK;
}
static HRESULT WINAPI ID3DXSpriteImpl_End(LPD3DXSPRITE iface)