private void InitializeD3D()
        {
            if (this.m_Filename != null)
            {
                try {
                    this.m_FormRenderSurface          = new FormDDSTGAPreviewRenderSurface(this);
                    this.m_FormRenderSurface.Anchor   = AnchorStyles.Top | AnchorStyles.Left;
                    this.m_FormRenderSurface.Location = new Point(0, 0);
                    this.m_FormRenderSurface.Size     = new Size(1, 1);
                    this.m_FormRenderSurface.Visible  = true;
                    this.panelRenderSurfaceContainer.Controls.Add(this.m_FormRenderSurface);

                    PresentParameters presentParameters = new PresentParameters();
                    presentParameters.Windowed               = true;
                    presentParameters.SwapEffect             = SwapEffect.Discard;
                    presentParameters.BackBufferFormat       = Format.Unknown;
                    presentParameters.AutoDepthStencilFormat = DepthFormat.D16;
                    presentParameters.EnableAutoDepthStencil = true;

                    DeviceCaps  deviceCaps  = Manager.GetDeviceCaps(Manager.Adapters.Default.Adapter, DeviceType.Hardware).DeviceCaps;
                    CreateFlags createFlags = ((deviceCaps.SupportsHardwareTransformAndLight) ? CreateFlags.HardwareVertexProcessing : CreateFlags.SoftwareVertexProcessing);
                    if (deviceCaps.SupportsPureDevice)
                    {
                        createFlags |= CreateFlags.PureDevice;
                    }

                    if (this.m_Device != null)
                    {
                        this.m_Device.Dispose();
                    }

                    this.m_Device                 = new Device(0, DeviceType.Hardware, this.m_FormRenderSurface, createFlags, presentParameters);
                    this.m_Device.DeviceReset    += new EventHandler(this.OnResetDevice);
                    this.m_Device.DeviceLost     += new EventHandler(this.OnDeviceLost);
                    this.m_Device.DeviceResizing += new CancelEventHandler(this.OnDeviceResizing);
                    OnResetDevice(this.m_Device, null);

                    SetUpViews();
                } catch {
                }
            }
        }
        private void InitializeD3D()
        {
            if (this.m_Filename != null) {
            try {
              this.m_FormRenderSurface = new FormDDSTGAPreviewRenderSurface(this);
              this.m_FormRenderSurface.Anchor = AnchorStyles.Top | AnchorStyles.Left;
              this.m_FormRenderSurface.Location = new Point(0, 0);
              this.m_FormRenderSurface.Size = new Size(1, 1);
              this.m_FormRenderSurface.Visible = true;
              this.panelRenderSurfaceContainer.Controls.Add(this.m_FormRenderSurface);

              PresentParameters presentParameters = new PresentParameters();
              presentParameters.Windowed = true;
              presentParameters.SwapEffect = SwapEffect.Discard;
              presentParameters.BackBufferFormat = Format.Unknown;
              presentParameters.AutoDepthStencilFormat = DepthFormat.D16;
              presentParameters.EnableAutoDepthStencil = true;

              DeviceCaps deviceCaps = Manager.GetDeviceCaps(Manager.Adapters.Default.Adapter, DeviceType.Hardware).DeviceCaps;
              CreateFlags createFlags = ((deviceCaps.SupportsHardwareTransformAndLight) ? CreateFlags.HardwareVertexProcessing : CreateFlags.SoftwareVertexProcessing);
              if (deviceCaps.SupportsPureDevice) {
            createFlags |= CreateFlags.PureDevice;
              }

              if (this.m_Device != null) {
            this.m_Device.Dispose();
              }

              this.m_Device = new Device(0, DeviceType.Hardware, this.m_FormRenderSurface, createFlags, presentParameters);
              this.m_Device.DeviceReset += new EventHandler(this.OnResetDevice);
              this.m_Device.DeviceLost += new EventHandler(this.OnDeviceLost);
              this.m_Device.DeviceResizing += new CancelEventHandler(this.OnDeviceResizing);
              OnResetDevice(this.m_Device, null);

              SetUpViews();
            } catch {
            }
              }
        }