DepthStencilSurface NotFoundException

Hi, trying to bind a device to a panel on a form.

public void InitPreviewPanel()
{
PresentationParameters pp = new PresentationParameters();
pp.AutoDepthStencilFormat = DepthFormat.Depth32;
pp.BackBufferHeight = this.pan_preview.Height;
pp.BackBufferWidth = this.pan_preview.Width;
pp.MultiSampleQuality = 0;
pp.MultiSampleType = MultiSampleType.None;

device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
DeviceType.Hardware, this.pan_preview.Handle,
CreateOptions.SoftwareVertexProcessing, pp);

If i break after the device creation I notice that the DepthStencilSurface property has thrown a NotFoundException. I can create a device through the normal XNA Express GraphicsComponenet method but want to bind it to a form. Do I assign the DepthStencilSurface afterwards or is it supposed to be created for me

TIA,

lushdog


Answer this question

DepthStencilSurface NotFoundException

  • laboremus

    Solved it myself. I'm glad I'm going this route as I actually get to see what all these properties are for.

    mySwapChain = new SwapChain(device, PP);

    DepthSurface = mySwapChain.GraphicsDevice.CreateDepthStencilSurface(
    PP.BackBufferWidth,
    PP.BackBufferHeight,
    DepthFormat.Depth32,
    PP.MultiSampleType,
    PP.MultiSampleQuality,
    true
    );

    device.DepthStencilSurface = DepthSurface;

    Now learning what handlers to add in for devices lost and devices changing.

  • DepthStencilSurface NotFoundException