Пример #1
0
        private static void Main()
        {
            var app    = new ExampleApplication();
            var visual = new MainVisual();

            app.ResourceManager.ShaderChanged += visual.ShaderChanged;
            LoadResources(app.ResourceManager);

            Stopwatch globalTime       = new Stopwatch();
            bool      doPostProcessing = false;

            app.Render += () =>
            {
                float time = (float)globalTime.Elapsed.TotalSeconds;
                if (doPostProcessing)
                {
                    visual.DrawWithPostProcessing(time);
                }
                else
                {
                    visual.Draw();
                }
            };

            app.Update += (t) => doPostProcessing = !Keyboard.GetState()[Key.Space];
            app.Resize += visual.Resize;
            app.GameWindow.ConnectEvents(visual.OrbitCamera);

            globalTime.Start();
            app.Run();
        }
Пример #2
0
        private static void Main()
        {
            var window = new ExampleWindow();

            var camera = window.GameWindow.CreateOrbitingCameraController(1.8f, 70, 0.1f, 50f);

            camera.View.TargetY = -0.3f;
            var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader);

            var  globalTime       = new GameTime();
            bool doPostProcessing = false;

            window.Render += () =>
            {
                if (doPostProcessing)
                {
                    visual.DrawWithPostProcessing(globalTime.AbsoluteTime, camera);
                }
                else
                {
                    visual.Draw(camera);
                }
            };

            window.Update += (t) => doPostProcessing = !window.Input.IsButtonDown("Space");
            window.Resize += visual.Resize;
            window.Run();
        }
        private static void DrawMainVisual(ExampleWindow window, ITransformation camera)
        {
            var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader);

            var  globalTime       = new GameTime();
            bool doPostProcessing = false;

            window.Render += () =>
            {
                if (doPostProcessing)
                {
                    visual.DrawWithPostProcessing(globalTime.AbsoluteTime, camera);
                }
                else
                {
                    visual.Draw(camera);
                }
            };

            window.Update += (t) => doPostProcessing = !Keyboard.GetState()[Key.Space];
            window.Resize += visual.Resize;
            window.Run();
        }