Fix ITexture::lock for D3D9Texture with RTT cubemaps.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5653 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2018-11-09 13:59:13 +00:00
parent 3b7216ed7c
commit bc525f5dcc
1 changed files with 8 additions and 2 deletions

View File

@ -216,7 +216,10 @@ void* CD3D9Texture::lock(E_TEXTURE_LOCK_MODE mode, u32 layer)
{ {
// Make RTT surface large enough for all miplevels (including 0) // Make RTT surface large enough for all miplevels (including 0)
D3DSURFACE_DESC desc; D3DSURFACE_DESC desc;
Texture->GetLevelDesc(0, &desc); if (Texture)
Texture->GetLevelDesc(0, &desc);
else if (CubeTexture)
CubeTexture->GetLevelDesc(0, &desc);
hr = Device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &RTTSurface, 0); hr = Device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &RTTSurface, 0);
if (FAILED(hr)) if (FAILED(hr))
{ {
@ -226,7 +229,10 @@ void* CD3D9Texture::lock(E_TEXTURE_LOCK_MODE mode, u32 layer)
} }
IDirect3DSurface9 *surface = 0; IDirect3DSurface9 *surface = 0;
hr = Texture->GetSurfaceLevel(0, &surface); if (Texture)
hr = Texture->GetSurfaceLevel(0, &surface);
else if (CubeTexture)
hr = CubeTexture->GetCubeMapSurface(static_cast<_D3DCUBEMAP_FACES>(layer), 0, &surface);
if (FAILED(hr)) if (FAILED(hr))
{ {
os::Printer::log("Could not lock DIRECT3D9 Texture", "Could not get surface.", ELL_ERROR); os::Printer::log("Could not lock DIRECT3D9 Texture", "Could not get surface.", ELL_ERROR);