Sign in to follow this  
rossbeater

CopyRects vs UpdateSurface problem

Recommended Posts

Dear nice people, I have been fumbling around trying to get this following to work in DirectX9. It used to work in DirectX8. Here is the original code... the LPDIRECT3DTEXTURE8 pTexture is initialized elsewhere HRESULT hr; LPDIRECT3DDEVICE8 pDev; LPDIRECT3DSURFACE8 pSurface = NULL, pStore = NULL; if(FAILED(hr=pTexture->GetSurfaceLevel (0, &pSurface))) { ... } if(FAILED(hr=pDev->CreateImageSurface (32, 32, D3DFMT_A8R8G8B, &pStore))) { ... } if(FAILED(hr=pDev->CopyRects (pSurface, NULL, pStore, 0))) { ... } And here is what I have come up with so far after googling and msdn for a day HRESULT hr; LPDIRECT3DDEVICE9 pDev; LPDIRECT3DSURFACE9 pSurface = NULL, pStore = NULL; if(FAILED(hr=pTexture->GetSurfaceLevel (0, &pSurface))) { ... } if(FAILED(hr=pDev->CreateOffscreenPlainSurface (32, 32, desc.Format, D3DPOOL_DEFAULT, &pStore, NULL))) { ... } if(FAILED(hr=pDev->UpdateSurface(pSurface, NULL, pStore, 0))) // FAILS HERE { ... } I think it's because the source surface must be created with D3DPOOL_SYSTEMMEM, also I am not sure whether I should set the D3DPOOL in CreateOffscreenPlainSurface to D3DPOOL_SCRATCH, so the return value is identical to CreateImageSurface, or should I use D3DPOOL_DEFAULT so that the destination, pStore, is created correctly to go with UpdateSurface...any help would be most heart warming.

Share this post


Link to post
Share on other sites
You might find D3DXLoadSurfaceFromMemory() easier to use, as it saves on going through a texture in system memory.

If you do really want to use UpdateSurface() then you'll need to use D3DPOOL_SYTEMMEM for the off screen texture. The default pool is in video ram.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this