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 Main() { var window = new ExampleWindow(debug: true); var camera = window.GameWindow.CreateFirstPersonCameraController(1f, new Vector3(36f, 0.1f, 30f), 70f, 0.01f, 300f); var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader); window.GameWindow.KeyDown += (s, a) => { if (a.Key == OpenTK.Input.Key.Tab) { visual.Wireframe = !visual.Wireframe; } }; var sampleSeries = new ExponentialSmoothing(0.01); QueryObject timeQuery = new QueryObject(); window.Render += () => { timeQuery.Activate(QueryTarget.TimeElapsed); visual.Draw(camera); timeQuery.Deactivate(); var timerQueryResult = timeQuery.ResultLong * 1e-6; sampleSeries.NewSample(timerQueryResult); window.GameWindow.Title = $"{sampleSeries.SmoothedValue:F0}ms"; }; window.Resize += visual.Resize; window.Resize += (w, h) => sampleSeries.Clear(); window.Run(); }
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(); }
private static void Main() { var window = new ExampleWindow(); var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader); window.GameWindow.AddWindowAspectHandling(visual.Camera.Projection); var movementState = window.GameWindow.AddFirstPersonCameraEvents(visual.Camera.View); window.Update += (dt) => visual.Camera.View.ApplyRotatedMovement(movementState.movement * 30 * dt); var sampleSeries = new ExponentialSmoothing(0.01); QueryObject timeQuery = new QueryObject(); window.Render += () => { timeQuery.Activate(QueryTarget.TimeElapsed); visual.Draw(); timeQuery.Deactivate(); var timerQueryResult = timeQuery.ResultLong * 1e-6; sampleSeries.NewSample(timerQueryResult); window.GameWindow.Title = $"{sampleSeries.SmoothedValue:F0}ms"; }; window.Resize += visual.Resize; window.Resize += (w, h) => sampleSeries.Clear(); window.Run(); }
private static void Main() { var window = new ExampleWindow(); var camera = window.GameWindow.CreateOrbitingCameraController(0.3f, 70, 0.01f, 30f); camera.View.Elevation = 15; var visual = new MainVisual(window.RenderContext.RenderState, window.ContentLoader); var sampleSeries = new ExponentialSmoothing(0.01); QueryObject timeQuery = new QueryObject(); window.Render += () => { var timerQueryResult = timeQuery.ResultLong * 1e-6; sampleSeries.NewSample(timerQueryResult); window.GameWindow.Title = $"{sampleSeries.SmoothedValue:F0}ms"; timeQuery.Activate(QueryTarget.TimeElapsed); visual.Draw(camera); timeQuery.Deactivate(); }; window.Resize += visual.Resize; window.Resize += (w, h) => sampleSeries.Clear(); 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(); }