コード例 #1
0
ファイル: Game.cs プロジェクト: diqost/bullet
        protected virtual void OnInitializeDevice()
        {
            Form.ClientSize = new Size(Width, Height);

            DeviceSettings9 settings = new DeviceSettings9();

            settings.CreationFlags   = CreateFlags.HardwareVertexProcessing;
            settings.Windowed        = true;
            settings.MultisampleType = MultisampleType.FourSamples;
            try
            {
                InitializeDevice(settings);
            }
            catch
            {
                // Disable 4xAA if not supported
                settings.MultisampleType = MultisampleType.None;
                try
                {
                    InitializeDevice(settings);
                }
                catch
                {
                    settings.CreationFlags = CreateFlags.SoftwareVertexProcessing;
                    try
                    {
                        InitializeDevice(settings);
                    }
                    catch
                    {
                        MessageBox.Show("Could not initialize DirectX device!");
                    }
                }
            }
        }
コード例 #2
0
ファイル: Game.cs プロジェクト: diqost/bullet
        /// <summary>
        /// Initializes a <see cref="DeviceContext9">Direct3D9 device context</see> according to the specified settings.
        /// The base class retains ownership of the context and will dispose of it when appropriate.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <returns>The initialized device context.</returns>
        protected void InitializeDevice(DeviceSettings9 settings)
        {
            var result = new DeviceContext9(Form, settings);

            apiContext = result;
            Context9   = result;
        }
コード例 #3
0
ファイル: DeviceContext9.cs プロジェクト: diqost/bullet
        internal DeviceContext9(Form form, DeviceSettings9 settings)
        {
            if (form.Handle == IntPtr.Zero)
            {
                throw new ArgumentException("Value must be a valid window handle.", "handle");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            this.settings = settings;

            PresentParameters = new PresentParameters();
            PresentParameters.BackBufferFormat       = Format.X8R8G8B8;
            PresentParameters.BackBufferCount        = 1;
            PresentParameters.BackBufferWidth        = form.ClientSize.Width;
            PresentParameters.BackBufferHeight       = form.ClientSize.Height;
            PresentParameters.Multisample            = settings.MultisampleType;
            PresentParameters.SwapEffect             = SwapEffect.Discard;
            PresentParameters.EnableAutoDepthStencil = true;
            PresentParameters.AutoDepthStencilFormat = Format.D24S8;
            PresentParameters.PresentFlags           = PresentFlags.DiscardDepthStencil;
            PresentParameters.PresentationInterval   = PresentInterval.Immediate;
            PresentParameters.Windowed           = settings.Windowed;
            PresentParameters.DeviceWindowHandle = form.Handle;

            direct3D = new Direct3D();
            Device   = new Device(direct3D, settings.AdapterOrdinal, DeviceType.Hardware, form.Handle, settings.CreationFlags, PresentParameters);
        }
コード例 #4
0
        internal DeviceContext9(Form form, DeviceSettings9 settings)
        {
            if (form.Handle == IntPtr.Zero)
                throw new ArgumentException("Value must be a valid window handle.", "handle");
            if (settings == null)
                throw new ArgumentNullException("settings");

            this.settings = settings;

            PresentParameters = new PresentParameters();
            PresentParameters.BackBufferFormat = Format.X8R8G8B8;
            PresentParameters.BackBufferCount = 1;
            PresentParameters.BackBufferWidth = form.ClientSize.Width;
            PresentParameters.BackBufferHeight = form.ClientSize.Height;
            PresentParameters.Multisample = settings.MultisampleType;
            PresentParameters.SwapEffect = SwapEffect.Discard;
            PresentParameters.EnableAutoDepthStencil = true;
            PresentParameters.AutoDepthStencilFormat = Format.D24S8;
            PresentParameters.PresentFlags = PresentFlags.DiscardDepthStencil;
            PresentParameters.PresentationInterval = PresentInterval.Immediate;
            PresentParameters.Windowed = settings.Windowed;
            PresentParameters.DeviceWindowHandle = form.Handle;

            direct3D = new Direct3D();
            Device = new Device(direct3D, settings.AdapterOrdinal, DeviceType.Hardware, form.Handle, settings.CreationFlags, PresentParameters);
        }
コード例 #5
0
        protected override void OnInitializeDevice()
        {
            Form.ClientSize = new Size(Width, Height);
            Form.Text = "BulletSharp - Multimaterial Mesh Demo";

            DeviceSettings9 settings = new DeviceSettings9();
            settings.CreationFlags = CreateFlags.HardwareVertexProcessing;
            settings.Windowed = true;
            settings.MultisampleType = MultisampleType.FourSamples;
            try
            {
                InitializeDevice(settings);
            }
            catch
            {
                // Disable 4xAA if not supported
                settings.MultisampleType = MultisampleType.None;
                InitializeDevice(settings);
            }
        }
コード例 #6
0
ファイル: Game.cs プロジェクト: raiker/BulletSharp
        protected virtual void OnInitializeDevice()
        {
            Form.ClientSize = new Size(Width, Height);

            DeviceSettings9 settings = new DeviceSettings9();
            settings.CreationFlags = CreateFlags.HardwareVertexProcessing;
            settings.Windowed = true;
            settings.MultisampleType = MultisampleType.FourSamples;
            try
            {
                InitializeDevice(settings);
            }
            catch
            {
                // Disable 4xAA if not supported
                settings.MultisampleType = MultisampleType.None;
                try
                {
                    InitializeDevice(settings);
                }
                catch
                {
                    settings.CreationFlags = CreateFlags.SoftwareVertexProcessing;
                    try
                    {
                        InitializeDevice(settings);
                    }
                    catch
                    {
                        MessageBox.Show("Could not initialize DirectX device!");
                    }
                }
            }
        }
コード例 #7
0
ファイル: Game.cs プロジェクト: raiker/BulletSharp
 /// <summary>
 /// Initializes a <see cref="DeviceContext9">Direct3D9 device context</see> according to the specified settings.
 /// The base class retains ownership of the context and will dispose of it when appropriate.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <returns>The initialized device context.</returns>
 protected void InitializeDevice(DeviceSettings9 settings)
 {
     var result = new DeviceContext9(Form, settings);
     apiContext = result;
     Context9 = result;
 }