Original Post
I am coding a small demo program. The basic idea is simple 2D pixel graphics. I create a random matrix, say 32x32 I then solve it interactively. Anyways I have to download data rapidly to the graphics card and I am very much unsure of what the optimal approach is under DirectX9? Under OpenGL I would proberly use pixel buffer objects to download the data async. Currently I have this simple piece of code to download pixel data.
HRESULT hr = S_OK;
D3DLOCKED_RECT LockedRect;
hr = texture->LockRect (0, &LockedRect, NULL, 0);
if (FAILED(hr))
return hr;
D3DXVECTOR4 *pbits = (D3DXVECTOR4 *) LockedRect.pBits;
for(int y = 0; y < int(image.height()); y++) {
DWORD dwOffset = y*image.width();
for(int x = 0; x < int(image.width()); x++) {
pbits[dwOffset+x] = image(x,y);
}
}
hr = texture->UnlockRect(0);
if(FAILED(hr))
return hr;
return S_OK;