Code:
HRESULTGenerateTexture(IDirect3DDevice8 *pD3Ddev, IDirect3DTexture8 **ppD3Dtex, DWORD colour32)
{
if(FAILED(pD3Ddev->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex)))
return E_FAIL;
WORD colour16 = ((WORD)((colour32>>28)&0xF)<<12)
|(WORD)(((colour32>>20)&0xF)<<8)
|(WORD)(((colour32>>12)&0xF)<<4)
|(WORD)(((colour32>>4)&0xF)<<0);
D3DLOCKED_RECT d3dlr;
(*ppD3Dtex)->LockRect(0, &d3dlr, 0, 0);
WORD *pDst16 = (WORD*)d3dlr.pBits;
for(int xy=0; xy < 8*8; xy++)
*pDst16++ = colour16;
(*ppD3Dtex)->UnlockRect(0);
return S_OK;
}
DirectX 9
Code:
GenerateTexture(pDevice,&Red, D3DCOLOR_ARGB(100,255,000,000));
GenerateTexture(pDevice,&Green, D3DCOLOR_ARGB(100,000,255,000));
GenerateTexture(pDevice,&Blue, D3DCOLOR_ARGB(100,000,000,255));
GenerateTexture(pDevice,&Yellow, D3DCOLOR_ARGB(100,255,255,000));
GenerateTexture(pDevice,&White, D3DCOLOR_ARGB(100,255,255,255));
GenerateTexture(pDevice,&Black, D3DCOLOR_ARGB(100,000,000,000));
GenerateTexture(pDevice,&Purple, D3DCOLOR_ARGB(100,150,000,255));
GenerateTexture(pDevice,&Orange, D3DCOLOR_ARGB(100,255,150,000));
Can be used for chams:
Code:
LPDIRECT3DTEXTURE8 Colors2[9] = { NULL, Red, Green, Blue, Yellow, White, Black, Purple, Orange };
pDevice->SetTexture(0,Colors2[4]); // blue
You can generate texture from a image with that code. Good luck