hello!
I'm creating a graphics core for my engine and I have landed at the texture blitting part. At first the draw function of my ID3DXSprite didn't work but after some trial and error it did. When I debug through my code it dóes say it is correct, but when I execute my app I see this:
Of course, this isn't the real texture I want to blit. But this is:
Why doesn't it show correctly? I've already walked through the blit function itself with a friend of mine, the texture's size is a power of 2...I'm out of ideas!
Here are my texture load- and blitfunctions:
BOOL cTexture::Load(cGraphics *Graphics, char *Filename, DWORD Transparent, D3DFORMAT Format)
{
Free();
if((m_Graphics = Graphics) == NULL) { return FALSE; }
if(Graphics->GetDeviceCOM() == NULL) { return FALSE; }
if(Filename == NULL) { return FALSE; }
if(FAILED(D3DXCreateTextureFromFileEx(Graphics->GetDeviceCOM(), Filename, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0,
Format, D3DPOOL_MANAGED, D3DX_FILTER_TRIANGLE, D3DX_FILTER_TRIANGLE, Transparent,
NULL, NULL, &m_Texture)))
{ return FALSE; }
m_Width = GetWidth();
m_Height = GetHeight();
return TRUE;
}
and
BOOL cTexture::Blit(long DestX, long DestY, long SrcX, long SrcY, long Width, long Height, float XScale, float YScale, D3DCOLOR Color)
{
RECT Rect;
ID3DXSprite *pSprite;
D3DXMATRIX matTemp;
if(m_Texture == NULL) { return FALSE; }
if(m_Graphics == NULL) { return FALSE; }
if((pSprite = m_Graphics->GetSpriteCOM()) == NULL) { return FALSE; }
if(!Width) { Width = m_Width; }
if(!Height) { Height = m_Height; }
Rect.left = SrcX;
Rect.top = SrcY;
Rect.right = Rect.left + Width;
Rect.bottom = Rect.top + Height;
D3DXMatrixIdentity(&matTemp);
D3DXMatrixScaling(&matTemp, XScale, YScale, 1.0f);
if(FAILED(pSprite->SetTransform(&matTemp))) { return FALSE; }
if(FAILED(pSprite->Draw(m_Texture,
&Rect,
NULL,
&D3DXVECTOR3(DestX, DestY, 0.0f),
Color)))
{
return FALSE;
}
return TRUE;
}
If you want more code, please ask! I really haven't got a clue anymore!
-Stenny
[Edited by - stenny on October 8, 2006 12:48:07 PM]
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel