protected override void ResizeDepthStencilBuffer(int width, int height, PixelFormat format) { var newTextureDescrition = DepthStencilBuffer.Texture.NativeDescription; newTextureDescrition.Width = width; newTextureDescrition.Height = height; // Manually update the texture DepthStencilBuffer.Texture.OnDestroyed(); // Force buffer destruction // TODO: We should track all user created depth buffer that points to depthStencilBuffer as well (or deny their creation?) DepthStencilBuffer.OnDestroyed(); // Put it in our back buffer texture DepthStencilBuffer.Texture.Recreate(newTextureDescrition); // Recreate render target DepthStencilBuffer.OnRecreate(); // Update variables // TODO: Should be kept readonly, maybe with reflection (ugly) or some other IL trick? DepthStencilBuffer.Texture.Width = width; DepthStencilBuffer.Texture.Height = height; DepthStencilBuffer.DescriptionInternal.Width = width; DepthStencilBuffer.DescriptionInternal.Height = height; }
protected override void ResizeDepthStencilBuffer(int width, int height, PixelFormat format) { var newTextureDescrition = DepthStencilBuffer.Description; newTextureDescrition.Width = width; newTextureDescrition.Height = height; // Manually update the texture DepthStencilBuffer.OnDestroyed(); // Put it in our back buffer texture DepthStencilBuffer.InitializeFrom(newTextureDescrition); }