Ejemplo n.º 1
0
        public static int Render(ulong[][] frames, int oneFrameTime, Render.BfMemoryConsoleRenderer renderer)
        {
            var overtimeFrames  = 0;
            var frameExpectedMs = oneFrameTime;

            var renderSw = new Stopwatch();

            renderSw.Start();
            foreach (var frame in frames)
            {
                renderer.DrawFrame(frame, true);
                var delay = frameExpectedMs - renderSw.ElapsedMilliseconds;

                if (delay > 0)
                {
                    Task.Delay((int)delay).Wait();
                }
                else
                {
                    overtimeFrames++;
                }

                frameExpectedMs += oneFrameTime;
            }

            return(overtimeFrames);
        }
Ejemplo n.º 2
0
        public void Run()
        {
            var renderer = new Render.BfMemoryConsoleRenderer(BitsInWord, WordsInRow, Rows)
            {
                ReverseByteOrder = false,
                AddSeparator     = false,
                AddFrameTime     = true
            };

            Console.WriteLine("Read and resizing images... ");
            var globalSw = new Stopwatch();

            globalSw.Start();
            var frames = LoadImages(ImagesDir, ImagesLoadParallelism, BitsInWord, (int)WordsInRow, (int)Rows);

            globalSw.Stop();
            Console.WriteLine($"Total {frames.Length} images. Elapsed seconds {globalSw.Elapsed.Seconds}");

            var oneFrameTime = 1000 / FramesPerSec;

            Console.WriteLine($"{oneFrameTime} ms per frame ({FramesPerSec} fps)");

            Delay();

            globalSw.Reset();
            globalSw.Start();

            var overtimeFrames = Render(frames, oneFrameTime, renderer);

            globalSw.Stop();
            Console.WriteLine($"Total render time: {globalSw.Elapsed}. {oneFrameTime}+ frames: {overtimeFrames}");
        }