Hi all
I'm trying to modify the contents of a texture dynamically (using DirectX9). It's an 8bit grayscale texture and what I'm currently doing is locking the texture like this:
D3DLOCKED_RECT lockedRect;
globalBlendMapTexture->LockRect(0, &lockedRect, 0, D3DLOCK_DISCARD);
blendMapData = (BYTE*)lockedRect.pBits;
blendMapPitch = lockedRect.Pitch;
...
int stride = blendMapPitch / width;
blendMapData[(y * blendMapPitch) + (x * stride)] = newValue;
globalBlendMapTexture->Unlock(0);
This works fine. I have something almost identical for getting the colour at a particular point and when I set the new colour and do a lookup, it gives me the new colour as expected.
The problem I have is that this new colour doesn't show when doing a lookup in my pixel shader, it still uses the old colour. I load the globalBlendMapTexture using this:
HRESULT hr = D3DXCreateTextureFromFileEx( device, L"some bitmap.bmp",
D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT,
D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN,
D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT,
0, NULL, NULL, &globalBlendMapTexture);
As per the MS docs, I've created it using D3DUSAGE_DYNAMIC and D3DPOOL_DEFAULT which should allow lockable textures (that bit works anyway by the looks of it). Is there something else I need to do for the pixel shader to pick up the change? I thought this would have been handled by the driver.
Thanks
[Edited by - RobMaddison on June 24, 2009 2:49:12 PM]