Describes the desired application configuration of a SlimDX sample.
Пример #1
0
 protected virtual Form CreateForm(SampleConfiguration config)
 {
     return(new RenderForm(config.WindowTitle)
     {
         ClientSize = new Size(config.WindowWidth, config.WindowHeight)
     });
 }
Пример #2
0
 protected virtual Form CreateForm(SampleConfiguration config)
 {
     return new RenderForm(config.WindowTitle)
     {
         ClientSize = new Size(config.WindowWidth, config.WindowHeight)
     };
 }
Пример #3
0
        /// <summary>
        /// Runs the sample.
        /// </summary>
        public void Run()
        {
            _configuration = OnConfigure();
            _form = CreateForm(_configuration);

            currentFormWindowState = _form.WindowState;

            bool isFormClosed = false;
            bool formIsResizing = false;

            _form.MouseClick += HandleMouseClick;
            _form.KeyDown += HandleKeyDown;
            _form.KeyUp += HandleKeyUp;
            _form.MouseDown += HandleMouseDown;
            _form.MouseUp += HandleMouseUp;
            _form.MouseMove += HandleMouseMove;
            _form.MouseWheel += HandleMouseMove;

            _form.Resize += (o, args) =>
            {
                if (_form.WindowState != currentFormWindowState)
                {
                    HandleResize(o, args);
                }

                currentFormWindowState = _form.WindowState;
            };

            _form.ResizeBegin += (o, args) => { formIsResizing = true; };
            _form.ResizeEnd += (o, args) =>
            {
                formIsResizing = false;
                HandleResize(o, args);
            };

            _form.Closed += (o, args) => { isFormClosed = true; };

            userInterface = new UserInterface();
            var stats = new Element();
            stats.SetBinding("Label", framesPerSecond);
            userInterface.Container.Add(stats);

            arcBall.SetWindow(_form.ClientSize.Width, _form.ClientSize.Height);

            var settings = new DeviceSettings9
            {
                AdapterOrdinal = 0,
                CreationFlags = CreateFlags.HardwareVertexProcessing,
                Width = WindowWidth,
                Height = WindowHeight
            };

            InitializeDevice(settings);

            OnInitialize();
            this.renderList.ForEach(x => x.Init());

            OnResourceLoad();

            clock.Start();
            MessagePump.Run(_form, () =>
            {
                if (isFormClosed)
                {
                    return;
                }

                Update();
                if (!formIsResizing)
                {
                    Render(false);
                }
            });

            OnResourceUnload();
        }