Original Post
I created a texture with the function:
if(FAILED(m_pd3dDevice->CreateTexture(256, 256, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED , &m_pFiremap)))
{
return E_FAIL;
}
Notice that the format of this texture I used is D3DFMT_A8R8G8B8 which reserves 32-bit of memory for it. 8 bits of it serve as blue, 8 as red, green, alpha, respectively.
And here is the code used to color the texture;
D3DLOCKED_RECT surfaceBit;
D3DSURFACE_DESC descBit;
if(FAILED(m_pFiremap->LockRect(0, &surfaceBit, NULL, 0)))
return E_FAIL;
char* surface = (char*)surfaceBit.pBits;
m_pFiremap->GetLevelDesc(0, &descBit);
UINT wtex = descBit.Width;
UINT htex = descBit.Height;
for(UINT y = 0; y < htex; y++)
{
for(UINT x = 0; x < wtex; x = x + 4)
{
surface[y * surfaceBit.Pitch + x] = (char)255;
surface[y * surfaceBit.Pitch + x + 1] = (char)0;
surface[y * surfaceBit.Pitch + x + 2] = (char)0;
surface[y * surfaceBit.Pitch + x + 3] = (char)0;
}
}
m_pFiremap->UnlockRect(0);
I found out that in the 32-bit memory of one pixel on my texture, first 8 is for blue, second 8 is for green, third 8 is for red. It makes sense that the forth 8-bit is for alpha. However, no matter what value I set to the forth 8-bit(I have tried to assign it 0, 1, 255), there is no effect on my texture at all. Can anyone tell me why?