Esempio n. 1
0
        public static RenderMetrics getInstance()
        {
            if (instance == null)
            {
                instance = new RenderMetrics();
            }

            return(instance);
        }
Esempio n. 2
0
        private void OnPaint(object sender, PaintEventArgs e)
        {
            frameCounter++;

            watch.Stop();
            base.OnPaint(e);

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            RenderScene();

            stopwatch.Stop();

            //this.Text = "Frame rendered in " + stopwatch.ElapsedMilliseconds + " ms. Between frames: "+watch.ElapsedMilliseconds+", points: "+QTreeLeaf.total_drawn_points_in_pass;

            //Console.WriteLine("f#"+frameCounter+" rendered in " + stopwatch.ElapsedMilliseconds + "ms, between frames: " + watch.ElapsedMilliseconds + "ms, points: " + QTreeLeaf.total_drawn_points_in_pass);

            if (frameCounterStopwatch.ElapsedMilliseconds > fpsSampleIntervalMilis)
            {
                frameCounterStopwatch.Stop();

                float fps     = 1000.0f * (float)frameCounter / frameCounterStopwatch.ElapsedMilliseconds;
                float avgTime = (float)frameCounterStopwatch.ElapsedMilliseconds / frameCounter;

                Text = String.Format("FPS: {0}, points drawn: {1}", fps, LasMetrics.GetInstance().pointsDrawn);

                RenderMetrics.getInstance().FPS             = fps;
                RenderMetrics.getInstance().frameRenderTime = avgTime;

                if (updateFormsEvent != null)
                {
                    updateFormsEvent();
                }

                frameCounter = 0;
                frameCounterStopwatch.Reset();
                frameCounterStopwatch.Start();
            }

            watch.Reset();
            watch.Start();
        }