bool CSpriteList::LoadTexture(const char *sz_filename, LPDIRECT3DTEXTURE8& texture)
{
//if(FAILED(D3DXCreateTextureFromFile(m_pD3DDevice, sz_filename, &texture)))
if(0 > D3DXCreateTextureFromFileEx(m_pD3DDevice, sz_filename,
D3DX_DEFAULT, D3DX_DEFAULT, 1,
0, D3DFMT_R8G8B8, D3DPOOL_MANAGED,
D3DX_FILTER_NONE, D3DX_FILTER_BOX, 0x00FF00FF,
NULL, NULL, &texture))
{
return false;
}
return true;
} (Not sure if the first byte of the color key should be FF or 00, I tried both and it seemed to have no difference. The file is a 24 bit bitmap image) This is how I render the textures with the transparent color (it returns it to opaque rendering at the end): int CSpriteList::Render()
{
m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
m_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
m_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
UpdateVertices();
m_pD3DDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(SPRITE_CUSTOMVERTEX));
m_pD3DDevice->SetVertexShader(SPRITE_D3DFVF_CUSTOMVERTEX);
if(m_pTileSet != NULL)
{
m_pD3DDevice->SetTexture(0, m_pTileSet);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
}
else
{
m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE);
}
m_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, m_numPolygons);
m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
m_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
m_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
return m_numPolygons;
} I don't want to post my entire initialization code so I'll just say that my front buffer is in this format: D3DFMT_X8R8G8B8 and the back buffer is in this format: D3DFMT_A8R8G8B8 and these are the other RenderStates that are set: m_pD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); m_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); m_pD3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); Hopefully I made an obvious mistake that someone notices! edit: dang, I always get the code tags wrong on this forum!