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); }
/// <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; }
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(nameof(settings)); } PresentParameters = new PresentParameters { BackBufferFormat = Format.X8R8G8B8, BackBufferCount = 1, BackBufferWidth = form.ClientSize.Width, BackBufferHeight = form.ClientSize.Height, Multisample = settings.MultisampleType, SwapEffect = SwapEffect.Discard, EnableAutoDepthStencil = true, AutoDepthStencilFormat = Format.D24S8, PresentFlags = PresentFlags.DiscardDepthStencil, PresentationInterval = PresentInterval.One, Windowed = settings.Windowed, DeviceWindowHandle = form.Handle }; _direct3D = new Direct3D(); Device = new Device(_direct3D, settings.AdapterOrdinal, DeviceType.Hardware, form.Handle, settings.CreationFlags, PresentParameters); }
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); }
protected void OnInitializeDevice() { Form.ClientSize = new Size(Width, Height); DeviceSettings9 settings = new DeviceSettings9 { CreationFlags = CreateFlags.HardwareVertexProcessing, Windowed = true, 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!"); return; } } } GraphicsLibraryManager.LibraryStarted(); }
protected 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!"); return; } } } GraphicsLibraryManager.LibraryStarted(); }