コード例 #1
0
ファイル: DemoApp.cs プロジェクト: thijsjvr/Tutorials
 /// <summary>
 /// Create Form for this demo.
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 protected virtual Form CreateForm(DemoConfiguration config)
 {
     return(new RenderForm(config.Title)
     {
         ClientSize = new Size(config.Width, config.Height)
     });
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: thijsjvr/Tutorials
        private static void Run()
        {
            // Prepare and run D3D11 wrapper
            var configuration = new DemoConfiguration("NoesisGUI Integration Sample", 1280, 720);

            app = new App();
            app.Run(configuration, contentLoadCallback: OnContentLoaded);
        }
コード例 #3
0
ファイル: DemoApp.cs プロジェクト: thijsjvr/Tutorials
        /// <summary>
        /// Runs the demo.
        /// </summary>
        public void Run(DemoConfiguration demoConfiguration)
        {
            this.demoConfiguration = demoConfiguration ?? new DemoConfiguration();
            this.form = this.CreateForm(this.demoConfiguration);
            this.Initialize(this.demoConfiguration);

            var isFormClosed   = false;
            var formIsResizing = false;

            this.form.MouseClick += this.HandleMouseClick;
            this.form.KeyDown    += this.HandleKeyDown;
            this.form.KeyUp      += this.HandleKeyUp;
            this.form.Resize     += (o, args) =>
            {
                if (this.form.WindowState != this.currentFormWindowState)
                {
                    this.HandleResize(o, args);
                }

                this.currentFormWindowState = this.form.WindowState;
            };

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

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

            this.LoadContent();

            this.clock.Start();
            this.BeginRun();
            RenderLoop.Run(
                this.form,
                () =>
            {
                if (isFormClosed)
                {
                    return;
                }

                this.OnUpdate();
                if (!formIsResizing)
                {
                    this.Render();
                }
            });

            this.UnloadContent();
            this.EndRun();

            // Dispose explicity
            this.Dispose();
        }
コード例 #4
0
ファイル: App.cs プロジェクト: thijsjvr/Tutorials
        protected override void Initialize(DemoConfiguration demoConfiguration)
        {
            base.Initialize(demoConfiguration);

            this.form.Closing           += (s, e) => this.Close?.Invoke();
            this.form.ClientSizeChanged += this.FormSizeChangedHandler;
            this.form.MouseMove         += this.FormMouseMoveHandler;
            this.form.MouseDown         += this.FormMouseDownHandler;
            this.form.MouseUp           += this.FormMouseUpHandler;
            this.form.KeyPress          += this.FormKeyPressHandler;
        }
コード例 #5
0
        protected override void Initialize(DemoConfiguration demoConfiguration)
        {
            // SwapChain description
            var desc = new SwapChainDescription()
            {
                BufferCount     = 1,
                ModeDescription = new ModeDescription(
                    demoConfiguration.Width,
                    demoConfiguration.Height,
                    new Rational(60, 1),
                    Format.R8G8B8A8_UNorm),
                IsWindowed        = true,
                OutputHandle      = this.DisplayHandle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput
            };

            // Create Device and SwapChain
            FeatureLevel featureLevel = new Device(DriverType.Hardware).FeatureLevel;

            if (featureLevel > FeatureLevel.Level_11_0)
            {
                featureLevel = FeatureLevel.Level_11_0;
            }

            Device.CreateWithSwapChain(
                DriverType.Hardware,
                DeviceCreationFlags.BgraSupport | DeviceCreationFlags.Debug,
                new[] { featureLevel },
                desc,
                out this.device,
                out this.swapChain);

            // Ignore all windows events
            var factory = this.swapChain.GetParent <Factory>();

            factory.MakeWindowAssociation(this.DisplayHandle, WindowAssociationFlags.IgnoreAll);

            this.CreateBackBuffer();
            this.CreateStencilBuffer();
        }
コード例 #6
0
ファイル: DemoApp.cs プロジェクト: thijsjvr/Tutorials
 /// <summary>
 /// In a derived class, implements logic to initialize the sample.
 /// </summary>
 protected abstract void Initialize(DemoConfiguration demoConfiguration);
コード例 #7
0
ファイル: App.cs プロジェクト: thijsjvr/Tutorials
 public void Run(DemoConfiguration appConfiguration, Action contentLoadCallback)
 {
     this.contentLoadCallback = contentLoadCallback;
     this.Run(appConfiguration);
 }