protected void CreateDxDevice()
        {
            if (GraphicsDeviceManager.CheckAdapterMeetsRequirements(0, minReqs))
            {
                GraphicsDevice3DOutputDescription outDesc = GraphicsDeviceManager.CreateOutputDescription(0, minReqs, desiredReqs);
                if (!GraphicsDeviceManager.CreateGraphicsDevice3D(outDesc, this, out outDesc, out device, out pParams))
                {
                    deviceFailMsg = "Managed DirectX: Failed to create device";
                }

                if (device != null)
                {
                    SetupView();
                }
            }
            else
            {
                deviceFailMsg = "Managed DirectX: Adapter does not meet minimum requirements";
            }
        }
        public static bool CreateGraphicsDevice3D(GraphicsDevice3DOutputDescription desc, Control deviceTarget,
                                                  out GraphicsDevice3DOutputDescription outDesc, out Device device,
                                                  out PresentParameters pParams)
        {
            try
            {
                pParams = new PresentParameters();
                if (desc.DepthFormat != DepthFormat.Unknown)
                {
                    pParams.EnableAutoDepthStencil = true;
                    pParams.AutoDepthStencilFormat = desc.DepthFormat;
                }
                if (desc.Format != Format.Unknown)
                {
                    pParams.BackBufferFormat = desc.Format;
                }
                pParams.MultiSample = desc.MultiSample;
                pParams.SwapEffect  = SwapEffect.Discard;
                pParams.Windowed    = desc.Windowed;

                device = new Device(desc.Adapter, desc.Type, deviceTarget, desc.CreateFlags, pParams);

                // capture actual final output description
                outDesc = new GraphicsDevice3DOutputDescription(desc.Adapter, desc.Windowed,
                                                                device.CreationParameters.DeviceType,
                                                                device.DisplayMode.Format,
                                                                device.GetBackBuffer(0, 0, BackBufferType.Mono).Description.MultiSampleType,
                                                                device.PresentationParameters.AutoDepthStencilFormat,
                                                                desc.CreateFlags);

                return(true);
            }
            catch (Exception)
            { }

            pParams = null;
            device  = null;
            outDesc = null;
            return(false);
        }
        public static bool CreateGraphicsDevice3D(GraphicsDevice3DOutputDescription desc, Control deviceTarget,
                                                  out GraphicsDevice3DOutputDescription outDesc, out Device device,
                                                  out PresentParameters pParams)
        {
            try
            {
                pParams = new PresentParameters();
                if (desc.DepthFormat != DepthFormat.Unknown)
                {
                    pParams.EnableAutoDepthStencil = true;
                    pParams.AutoDepthStencilFormat = desc.DepthFormat;
                }
                if (desc.Format != Format.Unknown)
                    pParams.BackBufferFormat = desc.Format;
                pParams.MultiSample = desc.MultiSample;
                pParams.SwapEffect = SwapEffect.Discard;
                pParams.Windowed = desc.Windowed;

                device = new Device(desc.Adapter, desc.Type, deviceTarget, desc.CreateFlags, pParams);

                // capture actual final output description
                outDesc = new GraphicsDevice3DOutputDescription(desc.Adapter, desc.Windowed,
                                                                device.CreationParameters.DeviceType,
                                                                device.DisplayMode.Format,
                                                                device.GetBackBuffer(0, 0, BackBufferType.Mono).Description.MultiSampleType,
                                                                device.PresentationParameters.AutoDepthStencilFormat,
                                                                desc.CreateFlags);

                return true;
            }
            catch (Exception)
            { }

            pParams = null;
            device = null;
            outDesc = null;
            return false;
        }