I'm pulling out my hair here trying to understand what I am doing wrong but I am having issues in loading and rendering pngs using D3DXLoadSurfaceFromFile() using the D3D9 API. They load but not correctly because they seem to be corrupt after rendering when the files are OK. A good example is from the files attached. The one on the left is loaded into a surface and being rendered using StrechRect(). However as you can see from the original on the right, its not doing it correctly and that not to mention that the alpha channel is being used around the character. Therefore, I should only be seeing the cleared back buffer and the silhouette of the character but I'm not. I don't know if there is anything I'm not doing but here is my initialisation and render code from the sprite class:
void MySprite::Initialise(LPCTSTR fileName)
{
//Create the offscreen surface to load the image
hResult = CreateOffscreenPlainSurface(
787,
428,
D3DFMT_A2R10G10B10,
D3DPOOL_DEFAULT,
&m_bitmap, // a previously defined offscreen surface
NULL);
if( fileName != L"" )
{
hResult = D3DXLoadSurfaceFromFile(
m_bitmap,
NULL,
NULL,
fileName,
NULL,
D3DX_DEFAULT,
0,
NULL );
}
}
}
void MySprite::Render(const RECT& destRect)
{
hResult = m_pD3Ddevice->StretchRect(
m_bitmap,
NULL,
m_backBuffer,
&destRect,
D3DTEXF_NONE);
}
I don't know if it is the format of the offscreen surface I'm using or what. BTW: the screen is being cleared but that is being called elsewhere. It is being cleared to D3DCOLOR_XRGB(255,100,0).
Also, I was playing around with using the system memory pool (D3DPOOL_SYSTEMMEM) for offscreen surface to be created to but that fails miserably. I even tried creating a REF device instead of using the HAL but to no avail. Any ideas on that?

New Topic/Question
Reply



MultiQuote






|