Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DeviceContext9"/> class.
        /// </summary>
        /// <param name="handle">The window handle to associate with the device.</param>
        /// <param name="settings">The settings used to configure the device.</param>
        internal DeviceContext9(IntPtr handle, DeviceSettings9 settings) {
            if (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 = settings.Width;
            PresentParameters.BackBufferHeight = settings.Height;
            PresentParameters.Multisample = MultisampleType.None;
            PresentParameters.SwapEffect = SwapEffect.Discard;
            PresentParameters.EnableAutoDepthStencil = true;
            PresentParameters.AutoDepthStencilFormat = Format.D16;
            PresentParameters.PresentFlags = PresentFlags.DiscardDepthStencil;
            PresentParameters.PresentationInterval = PresentInterval.Default;
            PresentParameters.Windowed = true;
            PresentParameters.DeviceWindowHandle = handle;

            direct3D = new Direct3D();
            Device = new Device(direct3D, settings.AdapterOrdinal, DeviceType.Hardware, handle, settings.CreationFlags, PresentParameters);
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DeviceContext9"/> class.
        /// </summary>
        /// <param name="handle">The window handle to associate with the device.</param>
        /// <param name="settings">The settings used to configure the device.</param>
        internal DeviceContext9(IntPtr handle, DeviceSettings9 settings)
        {
            if (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        = settings.Width;
            PresentParameters.BackBufferHeight       = settings.Height;
            PresentParameters.Multisample            = MultisampleType.None;
            PresentParameters.SwapEffect             = SwapEffect.Discard;
            PresentParameters.EnableAutoDepthStencil = true;
            PresentParameters.AutoDepthStencilFormat = Format.D16;
            PresentParameters.PresentFlags           = PresentFlags.DiscardDepthStencil;
            PresentParameters.PresentationInterval   = PresentInterval.Default;
            PresentParameters.Windowed           = true;
            PresentParameters.DeviceWindowHandle = handle;

            direct3D = new Direct3D();
            Device   = new Device(direct3D, settings.AdapterOrdinal, DeviceType.Hardware, handle, settings.CreationFlags, PresentParameters);
        }
Exemple #3
0
        /// <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.Handle, settings);

            userInterfaceRenderer = new UserInterfaceRenderer9(result.Device, settings.Width, settings.Height);
            apiContext            = result;
            Context9 = result;
        }
        protected override void OnInitialize() {
            var settings = new DeviceSettings9 {
                AdapterOrdinal = 0,
                CreationFlags = CreateFlags.HardwareVertexProcessing,
                Width = WindowWidth,
                Height = WindowHeight
            };

            InitializeDevice( settings );
        }
        /// <summary>
        /// Called to create the render device and window.
        /// </summary>
        protected override void OnInitialize()
        {
            // Build the device settings.
            var settings = new DeviceSettings9
            {
                AdapterOrdinal = 0,
                CreationFlags = CreateFlags.HardwareVertexProcessing,
                Width = WindowWidth,
                Height = WindowHeight
            };

            // Start up the graphics device.
            InitializeDevice(settings);
        }
Exemple #6
0
 /// <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.Handle, settings );
     userInterfaceRenderer = new UserInterfaceRenderer9( result.Device, settings.Width, settings.Height );
     apiContext = result;
     Context9 = result;
 }