Exemple #1
0
        private static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Args: filepath");
                return;
            }
            else
            {
                var file = args[0];
                var form = new RenderForm("Assimp Viewer");
                form.Show();
                using (var app = new AssimpViewWindow(file))
                {
                    app.Initialize(form);

                    using (var loop = new RenderLoop(form))
                    {
                        while (loop.NextFrame())
                        {
                            app.Update();
                            app.Render();
                        }
                    }
                }
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));

            var supported = Device.GetSupportedFeatureLevel();
            Console.WriteLine("device supported {0}", supported);

            if (supported < SharpDX.Direct3D.FeatureLevel.Level_10_0)
            return;

            TSOConfig tso_config;

            string tso_config_file = Path.Combine(Application.StartupPath, @"config.xml");
            if (File.Exists(tso_config_file))
            tso_config = TSOConfig.Load(tso_config_file);
            else
            tso_config = new TSOConfig();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new TSOForm(tso_config, args));

            TSOForm form = new TSOForm(tso_config, args);

            form.Show();
            using (RenderLoop loop = new RenderLoop(form))
            {
            while (loop.NextFrame())
            {
                form.FrameMove();
            }
            }
        }
Exemple #3
0
 public GraphicSystem(RenderLoop.RenderCallback LogicMethod, RenderLoop.RenderCallback RenderMethod)
 {
     _logicMethod = LogicMethod;
     _renderMethod = RenderMethod;
     _renderForm = new RenderForm();
     _graphicsDevice = new GraphicsDevice(this);
     _graphicsDevice.CreateDevice(_renderForm.Handle);
 }
 public void Run()
 {
     using (var Loop = new RenderLoop(Form))
     {
         while (Loop.NextFrame())
         {
             Update();
             Render();
         }
     }
 }
 private void Loop()
 {
     using (var loop = new RenderLoop(Core.Form))
     {
         while (loop.NextFrame())
         {
             Core.Update();
             Core.Render();
         }
     }
 }
        public AppWindow(IInputContext input)
        {
            _input = input;
            _form = new RenderForm();
            _renderLoop = new RenderLoop(Form);

            _form.Resize += OnFormResize;
            _form.Closed += OnFormClosed;
            _form.LostFocus += OnLostFocus;
            _form.MouseMove += OnMouseMove;
            _form.MouseDown += OnMouseDown;
            _form.MouseUp += OnMouseUp;
            _form.MouseWheel += OnMouseWheel;
        }
Exemple #7
0
 public void Run() {
     if (!IsInitialized || _hasRun) {
         return;
     }
     IsRunning = true;
     _hasRun = true;
     Timer.Reset();
     ControlWindow.Show();
     ControlWindow.Focus();
     using (var renderLoop = new RenderLoop(ControlWindow)) {
         while (renderLoop.NextFrame()) {
             Render();
         }
     }
 }
Exemple #8
0
        static void Main(string[] args)
        {
            var form = new RenderForm("HelloWorldD3D12");

            using (var helloTriangle = new HelloWorld())
            {
                form.Show();
                helloTriangle.Initialize(form);

                using (var loop = new RenderLoop(form))
                {
                    while (loop.NextFrame())
                    {
                        helloTriangle.Update();
                        helloTriangle.Render();
                    }
                }
            }
        }
        public static void Run()
        {
            var form = new RenderForm("HelloWorld D3D12");
            form.Icon = null;
            using (var helloTriangle = new DX12Test())
            {
                form.Show();
                helloTriangle.Initialize(form);

                using (var loop = new RenderLoop(form))
                {
                    while (loop.NextFrame())
                    {
                        helloTriangle.Update();
                        helloTriangle.Render();
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            var form = new RenderForm("CubeRender");

            using (var app = new CubeRender())
            {
                form.Show();
                app.Initialize(form);

                using (var loop = new RenderLoop(form))
                {
                    while (loop.NextFrame())
                    {
                        app.Update();
                        app.Render();
                    }
                }
            }
        }
Exemple #11
0
        /// <summary>
        /// Runs the specified main loop for the specified windows form.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="renderCallback">The rendering callback.</param>
        public static void Run(Control form, RenderCallback renderCallback)
        {
            if (form == null)
            {
                throw new ArgumentNullException("form");
            }
            if (renderCallback == null)
            {
                throw new ArgumentNullException("renderCallback");
            }

            form.Show();
            using (var renderLoop = new RenderLoop(form))
            {
                while (renderLoop.NextFrame())
                {
                    renderCallback();
                }
            }
        }
        static void Main(string[] args)
        {
            var form = new RenderForm("ModelRender");

            using (var app = new ModelRender())
            {
                form.Width = 1440;
                form.Height = 900;
                form.Show();
                app.Initialize(form);

                using (var loop = new RenderLoop(form))
                {
                    while (loop.NextFrame())
                    {
                        app.Update();
                        app.Render();
                    }
                }
            }
        }
Exemple #13
0
        static void Main(string[] args)
        {
            var form = new RenderForm("HelloWorldD3D12");

            using (var helloTriangle = new HelloWorldShared.HelloWorld())
            {
                form.Show();
                form.ClientSizeChanged += (o, e) => helloTriangle.Resize(form.ClientSize.Width, form.ClientSize.Height);

                helloTriangle.Initialize(form);

                using (var loop = new RenderLoop(form))
                {
                    while (loop.NextFrame())
                    {
                        helloTriangle.Update();
                        helloTriangle.Render();
                    }
                }
            }
        }
        static void Main()
        {
            var form = new RenderForm("Hello Bundles");
            form.Width = 1280;
            form.Height = 800;
            form.Show();

            using (HelloBundles app = new HelloBundles())
            {
                app.Initialize(form);

                using (var loop = new RenderLoop(form))
                {
                    while (loop.NextFrame())
                    {
                        app.Update();
                        app.Render();
                    }
                }
            }
        }
        static void Main()
        {
            var form = new RenderForm("Hello Render Target. Press 1-2-3");
            form.Width = 1280;
            form.Height = 800;
            form.Show();

            using (HelloMesh app = new HelloMesh())
            {
                app.Initialize(form);

                using (var loop = new RenderLoop(form))
                {
                    while (loop.NextFrame())
                    {
                        app.Update();
                        app.Render();
                    }
                }
            }
        }
Exemple #16
0
        /// <summary>
        /// Runs the specified main loop for the specified windows form.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="renderCallback">The rendering callback.</param>
        /// <param name="useApplicationDoEvents">if set to <c>true</c> indicating whether the render loop should use the default <see cref="Application.DoEvents"/> instead of a custom window message loop lightweight for GC. Default is false.</param>
        /// <exception cref="System.ArgumentNullException">form
        /// or
        /// renderCallback</exception>
        public static void Run(Control form, RenderCallback renderCallback, bool useApplicationDoEvents = false)
        {
            if (form == null)
            {
                throw new ArgumentNullException("form");
            }
            if (renderCallback == null)
            {
                throw new ArgumentNullException("renderCallback");
            }

            form.Show();
            using (var renderLoop = new RenderLoop(form)
            {
                UseApplicationDoEvents = useApplicationDoEvents
            })
            {
                while (renderLoop.NextFrame())
                {
                    renderCallback();
                }
            }
        }
Exemple #17
0
        static void Main()
        {
            var form = new RenderForm("Hello Constant Buffer")
            {
                Width = 1280,
                Height = 800
            };
            form.Show();

            using (var app = new HelloConstBuffers())
            {
                app.Initialize(form);

                using (var loop = new RenderLoop(form))
                {
                    while (loop.NextFrame())
                    {
                        app.Update();
                        app.Render();
                    }
                }
            }
        }
        /// <inheritdoc />
        internal override void Run()
        {
            Debug.Assert(InitCallback != null);
            Debug.Assert(RunCallback != null);

            InitCallback();

            try
            {
                // Use custom render loop
                Control.Show();
                using (renderLoop = new RenderLoop(Control))
                {
                    while (renderLoop.NextFrame())
                    {
                        if (Exiting)
                        {
                            if (Control != null)
                            {
                                Control.Dispose();
                                Control = null;
                            }
                            break;
                        }

                        RunCallback();
                    }
                }
            }
            finally
            {
                if (ExitCallback != null)
                {
                    ExitCallback();
                }
            }
        }
Exemple #19
0
        private void RunRenderLoop()
        {
            Debug.Assert(InitCallback != null);
            Debug.Assert(RunCallback != null);

            InitCallback();

            try
            {
                // Use custom render loop
                // Show the control for WinForm, let HwndHost show it for WPF
                if (wpfBorderControl == null)
                    Control.Show();

                using (renderLoop = new RenderLoop(Control) { UseApplicationDoEvents = GameContext.UseApplicationDoEvents })
                {
                    while (renderLoop.NextFrame())
                    {
                        if (Exiting)
                        {
                            if (Control != null)
                            {
                                Control.Dispose();
                                Control = null;
                            }
                            break;
                        }

                        RunCallback();
                    }
                }
            }
            finally
            {
                if (ExitCallback != null)
                {
                    ExitCallback();
                }
            }
        }
Exemple #20
0
 public void Run(RenderLoop.RenderCallback renderCallback)
 {
     this._form.Show();
     while (this._isAlive)
     {
       if (RenderLoop.UseCustomDoEvents)
       {
     Win32Native.NativeMessage lpMsg;
     while (Win32Native.PeekMessage(out lpMsg, this._windowHandle, 0, 0, 0) != 0)
     {
       if (Win32Native.GetMessage(out lpMsg, this._windowHandle, 0, 0) == -1)
       {
     throw new InvalidOperationException(string.Format((IFormatProvider) CultureInfo.InvariantCulture, "An error happened in rendering loop while processing windows messages. Error: {0}", new object[1]
     {
       (object) Marshal.GetLastWin32Error()
     }));
       }
       else
       {
     Win32Native.TranslateMessage(ref lpMsg);
     Win32Native.DispatchMessage(ref lpMsg);
       }
     }
       }
       else
     Application.DoEvents();
       if (this._isAlive)
     renderCallback();
     }
     this._form.Disposed -= new EventHandler(this._form_Disposed);
     MessageFilterHook.RemoveMessageFilter(this._windowHandle, (IMessageFilter) this);
 }
Exemple #21
0
 public static void Run(ApplicationContext context, RenderLoop.RenderCallback renderCallback)
 {
     RenderLoop.Run((Control) context.MainForm, renderCallback);
 }
        /// <summary>
        /// Runs the specified main loop for the specified windows form.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="renderCallback">The rendering callback.</param>
        /// <param name="useApplicationDoEvents">if set to <c>true</c> indicating whether the render loop should use the default <see cref="Application.DoEvents"/> instead of a custom window message loop lightweight for GC. Default is false.</param>
        /// <exception cref="System.ArgumentNullException">form
        /// or
        /// renderCallback</exception>
        public static void Run(Control form, RenderCallback renderCallback, bool useApplicationDoEvents = false)
        {
            if(form == null) throw new ArgumentNullException("form");
            if(renderCallback == null) throw new ArgumentNullException("renderCallback");

            form.Show();
            using (var renderLoop = new RenderLoop(form) { UseApplicationDoEvents = useApplicationDoEvents })
            {
                while(renderLoop.NextFrame())
                {
                    renderCallback();
                }
            }
        }
Exemple #23
0
 public static void Run(Control form, RenderLoop.RenderCallback renderCallback)
 {
     new RenderLoop.ProxyNativeWindow(form).Run(renderCallback);
 }
Exemple #24
0
        /// <summary>
        /// Runs the specified main loop for the specified windows form.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="renderCallback">The rendering callback.</param>
        public static void Run(Control form, RenderCallback renderCallback)
        {
            if(form == null) throw new ArgumentNullException("form");
            if(renderCallback == null) throw new ArgumentNullException("renderCallback");

            form.Show();
            using(var renderLoop = new RenderLoop(form))
            {
                while(renderLoop.NextFrame())
                {
                    renderCallback();
                }
            }
        }
Exemple #25
0
 public static void Run(ApplicationContext context, RenderLoop.RenderCallback renderCallback)
 {
     RenderLoop.Run((Control)context.MainForm, renderCallback);
 }