Exemplo n.º 1
0
        /// <summary>
        /// Pipes an OpenGL rendering; converting the frame buffer to ASCII text,
        /// and outputting into the System.Console.
        /// </summary>
        /// <param name="rc">
        /// The rendering context.
        /// </param>
        /// <param name="renderBlock">
        /// The rendering method to execute.
        /// </param>
        public void PipeToConsole(RenderingContext rc, Action renderBlock)
        {
            Bitmap frame;
            string frameBuffer;
            int    rows;
            int    columns;

            frame = CaptureFramebufferAsBitmap(rc, renderBlock);

            ImageTexture.Scale(ref frame, new Size(100, 100));
            frame.RotateFlip(RotateFlipType.Rotate180FlipX);

            //frame.Save("D:\\test-frame2.png");

            frameBuffer = asciiTextImageTranslator(frame, out rows, out columns);

            frame.Dispose();

            Console.Clear();
            //Console.WindowWidth = rows;
            //Console.WindowHeight = columns + 1;
            //Console.BufferWidth = rows + 1;
            //Console.BufferHeight = columns + 1;

            Console.Write(frameBuffer);
        }