コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Jonnyf16/Framework
 private void Render()
 {
     glTimerRender.Activate(QueryTarget.TimeElapsed);
     GL.Clear(ClearBufferMask.ColorBufferBit);
     shader.Activate();
     GL.DrawArrays(PrimitiveType.Quads, 0, 4);
     shader.Deactivate();
     glTimerRender.Deactivate();
     Console.Write("Rendertime:");
     Console.Write(glTimerRender.ResultLong / 1e6);
     Console.WriteLine("msec");
 }
コード例 #5
0
        private void Render()
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.Color3(OpenTK.Color.White);
            queryA.Activate(OpenTK.Graphics.OpenGL4.QueryTarget.SamplesPassed);
            DrawBox(boxA, 0.0f);
            queryA.Deactivate();

            GL.Color3(OpenTK.Color.Red);
            queryB.Activate(OpenTK.Graphics.OpenGL4.QueryTarget.SamplesPassed);
            DrawBox(boxB, 0.5f);
            queryB.Deactivate();

            Console.WriteLine(queryA.Result);
            Console.WriteLine(queryB.Result);
        }