please examine a code snippet below:
var form = new Form(); form.Width = 640; form.Height = 480; var pp = new PresentParameters(); pp.DeviceWindowHandle = form.Handle; pp.BackBufferWidth = form.Width; pp.BackBufferHeight = form.Height; var device = new Device(new Direct3D(), 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, pp); var swapChain = new SwapChain(device, pp); Surface surface = swapChain.GetBackBuffer(0); swapChain.Dispose();Why the surface resource is still alive even after disposing swap chain? My expectation is that the surface is a part of the swapChain and it should be disposed after the swap chain has been disposed..
Is this pseudo code correct for case with multiple swap chains, i mean is it normal situation when the back buffer surface disposes in each frame?
Device m_device;
void RenderFrame(SwapChain swapChain)
{
Surface surface = swapChain.GetBackBuffer(0);
m_device.SetRenderTarget(0, surface);
// Render 3D scene
surface.Dispose();
}






