Example #1
0
        private static void Main()
        {
            var wnd    = new GameWindow();
            var resMng = new ResourceManager();

            Resources.LoadResources(resMng);
            var visual = new MainVisual();

            wnd.Resize += (s, a) => GL.Viewport(0, 0, wnd.Width, wnd.Height);
            wnd.ConnectEvents(visual.Camera);
            wnd.VSync = VSyncMode.Off;

            //var x = -1f;
            //GL.ClearColor(.5f, .2f, 0, 1);
            wnd.Visible = true;
            //main loop
            while (wnd.Exists)
            {
                //if (x < 1) x += .01f; else x = -1;
                //GL.Clear(ClearBufferMask.ColorBufferBit);
                //GL.Begin(PrimitiveType.Triangles);
                //GL.Vertex2(x, 0);
                //GL.Vertex2(x + 1, 0);
                //GL.Vertex2(x, 1);
                //GL.End();
                visual.Render();
                wnd.Context.SwapBuffers();
                wnd.ProcessEvents();                 //this call could destroy window, so do all stuff that needs the window (like gl) before
            }
        }
        private static void Main()
        {
            var window = new ExampleWindow(debug: true);
            var camera = window.GameWindow.CreateOrbitingCameraController(3f, 70f, 0.1f, 500f);
            var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader);

            window.Render += () => visual.Render(camera, camera.View.CalcPosition());
            window.Run();
        }
        private static void Main()
        {
            var window = new ExampleWindow();
            var orbit  = window.GameWindow.CreateOrbitingCameraController(0.5f, 70, 0.01f, 50f);
            var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader);

            window.Render += () => visual.Render(orbit, orbit.CalcPosition());
            window.Run();
        }
Example #4
0
        private static void Main()
        {
            var window = new ExampleWindow();
            var camera = window.GameWindow.CreateOrbitingCameraController(30, 90, 0.1f, 500f);
            var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader);

            window.Render += () => visual.Render(camera);
            window.Run();
        }
        private static void Main()
        {
            var window = new ExampleWindow();
            var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader);
            var time   = new GameTime();

            window.Render += () => visual.Render(time.AbsoluteTime);
            window.Resize += visual.Resize;
            window.Run();
        }
        private static void Main()
        {
            var window = new ExampleWindow();
            //window.SetContentSearchDirectory(Path.GetDirectoryName(PathTools.GetSourceFilePath())); //would be faster if you only specify a subdirectory
            var orbit  = window.GameWindow.CreateOrbitingCameraController(15, 30, 0.1f, 50f);
            var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader);

            window.Render += () => visual.Render(orbit, orbit.CalcPosition());
            window.Run();
        }
        private static void Main()
        {
            var window = new ExampleWindow();

            window.SetContentSearchDirectory(Path.GetDirectoryName(PathTools.GetSourceFilePath()));             //would be faster if you only specify a subdirectory
            var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader);
            var time   = new GameTime();

            window.Render += () => visual.Render(time.AbsoluteTime);
            window.Run();
        }
Example #8
0
        private static void Main()
        {
            var window = new ExampleWindow();
            var camera = window.GameWindow.CreateOrbitingCameraController(30, 90, 0.1f, 500f);
            //var camera = window.GameWindow.CreateFirstPersonCameraController(1f, new Vector3(0, 0, 10), 70f, 0.1f, 20f);

            var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader);

            window.Render += () => visual.Render(camera);
            window.Run();
        }
Example #9
0
        private static void Main()
        {
            var window = new ExampleWindow();
            var camera = window.GameWindow.CreateOrbitingCameraController(1.5f, 90f, 0.1f, 50f);

            camera.View.Azimuth   = 90;
            camera.View.Elevation = 20;
            var visual = new MainVisual(window.RenderContext, window.ContentLoader);

            window.Render += () => visual.Render(camera);
            window.Run();
        }
Example #10
0
        private MyApplication()
        {
            var mode = new GraphicsMode(new ColorFormat(32), 24, 8, 0);

            gameWindow              = new GameWindow(1024, 1024, mode, "Example", GameWindowFlags.Default, DisplayDevice.Default, 4, 3, GraphicsContextFlags.ForwardCompatible);
            gameWindow.WindowState  = WindowState.Fullscreen;
            gameWindow.KeyDown     += GameWindow_KeyDown;
            gameWindow.Resize      += (s, arg) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
            gameWindow.RenderFrame += (s, arg) => visual.Render();
            gameWindow.RenderFrame += (s, arg) => gameWindow.SwapBuffers();
            visual = new MainVisual();
        }
Example #11
0
        private static void Main()
        {
            var window = new ExampleWindow();
            var camera = window.GameWindow.CreateOrbitingCameraController(2, 70, 0.1f, 20f);

            camera.View.Elevation = 15;
            var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader);
            var time   = new GameTime();

            window.Render += () => visual.Render(time.DeltaTime, camera);
            window.Resize += visual.Resize;
            window.Run();
        }
Example #12
0
        private static void Main()
        {
            var app    = new ExampleApplication();
            var model  = new Model();
            var visual = new MainVisual();

            app.ResourceManager.ShaderChanged += visual.ShaderChanged;
            LoadResources(app.ResourceManager);
            app.Render += () => visual.Render(model.Bodies);
            app.Update += model.Update;
            app.GameWindow.ConnectEvents(visual.Camera);
            app.Run();
        }
Example #13
0
        private static void Main()
        {
            var window = new ExampleWindow();
            var model  = new Model();
            var camera = window.GameWindow.CreateOrbitingCameraController(30, 90, 0.1f, 500f);
            var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader);

            var time = new GameTime();

            window.Render += () => visual.Render(model.Bodies, time.AbsoluteTime, camera);
            window.Update += model.Update;
            window.Run();
        }
        private static void Main()
        {
            var window     = new ExampleWindow();
            var controller = new Controller();

            var camera = window.GameWindow.CreateOrbitingCameraController(2, 70, 0.1f, 20f);

            camera.Elevation = 15;
            var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader);

            var time = new GameTime();

            window.Render += () => visual.Render(camera);
            window.Update += (t) => visual.Update(time.AbsoluteTime);
            window.Run();
        }
Example #15
0
        private static void Main()
        {
            var window = new ExampleWindow();
            var camera = window.GameWindow.CreateOrbitingCameraController(3, 70, 0.1f, 20);

            camera.View.Elevation = 35;
            camera.View.Azimuth   = 60;
            var visual     = new MainVisual(window.RenderContext.RenderState, window.ContentLoader);
            var time       = new GameTime();
            var timeSeries = new ExponentialSmoothing(0.01);

            window.Render += () =>
            {
                time.NewFrame();
                var deltaTime = visual.Render(time.DeltaTime, camera);
                timeSeries.NewSample(deltaTime);
                window.GameWindow.Title = $"{timeSeries.SmoothedValue:F2}msec";
            };
            window.Resize += visual.Resize;
            window.Run();
        }