|
|
I am trying to load data straight into a newly created texture. But it doesn't seem to be working out right. I am not sure if the addressing is being done correctly because even when I set the RGB value to 255,0,0...it comes out red partially on the model, some area done even get textured. BTW..its supposed to be converting a PCX file into a texture for my md2 loader.
// Create a texture and copy Image into surface
hResult = D3DXCreateTexture(g_pDirect3DDevice,wWidth+1,wHeight+1,
3DX_DEFAULT,0,
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,&pTexture);
if (FAILED(hResult))
{
return -1;
}
pTexture->GetSurfaceLevel(0,&texSurface);
texSurface->LockRect(&texRect,NULL,0);
pData = (DWORD*)texRect.pBits;
for (y=0; y<=wHeight; y++)
for (x=0;x<=wWidth;x++)
{
//pData[ y * (texRect.Pitch/4) + x] = D3DCOLOR_ARGB(0,255,0,0);
pData[ y * (texRect.Pitch/4) + x] = D3DCOLOR_ARGB(0,
palette[ indexdata[x+y*(wWidth+1)]], // R
palette[ indexdata[x+y*(wWidth+1)]] + 1, // G
palette[ indexdata[x+y*(wWidth+1)]] + 2); // B
}
texSurface->UnlockRect();
|
|