private static void Draw()
        {
            // Draw console background
            GL.BindTexture(GL.GL_TEXTURE_2D, _ConsoleBackground.GLTextureNumber);
            GL.Begin(GL.GL_QUADS);
            GL.Color4f(0.0f, 0.0f, 0.0f, 0.0f);         // Black, transparent
            GL.TexCoord2f(0.0f, 0.0f); GL.Vertex2f(0.0f, 0.0f);
            GL.TexCoord2f(0.0f, 1.0f); GL.Vertex2f(0.0f, _ScreenHeight);
            GL.TexCoord2f(1.0f, 1.0f); GL.Vertex2f(_ScreenWidth, _ScreenHeight);
            GL.TexCoord2f(1.0f, 0.0f); GL.Vertex2f(_ScreenWidth, 0.0f);
            GL.End();

            // Draw text lines
            DrawLines(_TopLineIndex, _BottomLineIndex);

            // Write the console input character
            if (String.IsNullOrEmpty(ConsoleLogManager.ReadBuffer()))
            {
                Write("> ");
            }

            // Draw text input line, because we have initially a long OpenGL loading log, the cursor is always at the last line
            DrawLine((uint)(_LinesPerScreen * 8), ConsoleLogManager.ReadBuffer());

            // Set the cursor position for text input
            _CursorPosX = (ushort)ConsoleLogManager.GetBufferLength();
            _CursorPosY = _LinesPerScreen;
        }
        public static void Write(string Line)
        {
            ConsoleLogManager.Write(Line);

            // Set the cursor position for text input
            _CursorPosX = (ushort)ConsoleLogManager.GetBufferLength();
            _CursorPosY = _LinesPerScreen;
        }
        private static void DrawLines(uint FirstLine, uint LastLine)
        {
            for (uint Counter = FirstLine; Counter <= LastLine; Counter++)
            {
                string Line     = ConsoleLogManager.GetLineByNumber(Counter);
                uint   LinePosY = (Counter - FirstLine) * 8;

                DrawLine(LinePosY, Line);
            }
        }
 private static void Command_dumpconsole(string[] parameters)
 {
     if (parameters == null || parameters.Length != 1)
     {
         ConsoleManager.WriteLine("HELP: dumpconsole <textfilename>.txt");
     }
     else
     {
         ConsoleLogManager.DumpToFile(parameters[0]);
     }
 }
        public static void WriteLine()
        {
            ConsoleLogManager.WriteLine();

            if (ConsoleLogManager.Count <= _LinesPerScreen)
            {
                _TopLineIndex    = 1;
                _BottomLineIndex = _TopLineIndex + ConsoleLogManager.Count - 1;
            }
            else
            {
                _TopLineIndex++;
                _BottomLineIndex = _TopLineIndex + _LinesPerScreen - 1;
            }
        }
Example #6
0
        public unsafe static void Keyboard(byte key, int x, int y)
        {
            //Console.WriteLine("Key = " + key);

            if (ConsoleManager.IsOpen)
            {   // If console is open...
                switch (key)
                {
                case 96:        // "~" key pressed
                case 126:
                    ConsoleManager.Close();
                    Reshape(ConsoleVarManager.GetValueToUShort("ScreenWidth"), ConsoleVarManager.GetValueToUShort("ScreenHeight"));
                    break;

                case 8:         // Backspace key pressed
                case 127:       // Del key pressed
                    ConsoleLogManager.DeleteBufferChar();
                    break;

                case 9:         // Tab key pressed; do nothing
                case 27:        // Escape key pressed; do nothing
                    break;

                case 13:        // Enter key pressed
                    string Command = ConsoleLogManager.ReadBuffer();
                    // Flush the buffer
                    ConsoleManager.WriteLine();
                    // Execute command
                    CommandManager.ExecuteCommand(Command);
                    // Redisplay the console
                    ConsoleManager.Open();
                    break;

                default:
                    byte *keyptr = &key;
                    ConsoleManager.Write(new string((sbyte *)keyptr));
                    break;
                }
            }
            else
            {   // If console is closed
                switch (key)
                {
                case 96:        // "~" key pressed
                case 126:
                    ConsoleManager.Open();
                    Reshape(ConsoleVarManager.GetValueToUShort("ScreenWidth"), ConsoleVarManager.GetValueToUShort("ScreenHeight"));
                    break;
                }

                if (ConsoleVarManager.GetValueToByte("DemoFreeglut") == 1)
                {
                    switch (key)
                    {
                    case 81:        // 'Q' key pressed
                    case 113:
                        SpinIncrement += 0.25f;
                        break;

                    case 90:        // 'Z' key pressed
                    case 122:
                        SpinIncrement -= 0.25f;
                        break;

                    case 70:        // 'F' key pressed
                    case 102:
                        FG.FullScreenToggle();
                        break;

                    case 49:        // '1', '2', '3', '4', '5' key pressed
                    case 50:
                    case 51:
                    case 52:
                    case 53:
                        key       -= 48;
                        DrawObject = (ObjectNames)key;
                        break;

                    case 65:        // 'A' key pressed
                    case 97:
                        GL.MatrixMode(GL.GL_PROJECTION);
                        GL.Translatef(-1.0f, 0.0f, 0.0f);
                        GL.MatrixMode(GL.GL_MODELVIEW);
                        break;

                    case 83:        // 'S' key pressed
                    case 115:
                        GL.MatrixMode(GL.GL_PROJECTION);
                        GL.Translatef(0.0f, -1.0f, 0.0f);
                        GL.MatrixMode(GL.GL_MODELVIEW);
                        break;

                    case 68:        // 'D' key pressed
                    case 100:
                        GL.MatrixMode(GL.GL_PROJECTION);
                        GL.Translatef(+1.0f, 0.0f, 0.0f);
                        GL.MatrixMode(GL.GL_MODELVIEW);
                        break;

                    case 87:        // 'W' key pressed
                    case 119:
                        GL.MatrixMode(GL.GL_PROJECTION);
                        GL.Translatef(0.0f, +1.0f, 0.0f);
                        GL.MatrixMode(GL.GL_MODELVIEW);
                        break;

                    case 27:        // ESCAPE key pressed, so exit the program
                        RotateAroundX = false;
                        RotateAroundY = false;
                        RotateAroundZ = false;

                        FG.IdleFunc(null);
                        FG.KeyboardFunc(null);
                        FG.MouseFunc(null);
                        FG.ReshapeFunc(null);
                        FG.DestroyWindow(FG.GetWindow());
                        break;
                    }
                }

                if (ConsoleVarManager.GetValueToByte("DemoGUI") == 1)
                {
                    switch (key)
                    {
                    case 81:        // 'Q' key pressed
                    case 113:
                        SpinIncrement += 0.25f;
                        break;

                    case 90:        // 'Z' key pressed
                    case 122:
                        SpinIncrement -= 0.25f;
                        break;

                    case 70:        // 'F' key pressed
                    case 102:
                        FG.FullScreenToggle();
                        break;

                    case 65:        // 'A' key pressed
                    case 97:
                        GL.MatrixMode(GL.GL_PROJECTION);
                        GL.Translatef(-1.0f, 0.0f, 0.0f);
                        GL.MatrixMode(GL.GL_MODELVIEW);
                        break;

                    case 83:        // 'S' key pressed
                    case 115:
                        GL.MatrixMode(GL.GL_PROJECTION);
                        GL.Translatef(0.0f, -1.0f, 0.0f);
                        GL.MatrixMode(GL.GL_MODELVIEW);
                        break;

                    case 68:        // 'D' key pressed
                    case 100:
                        GL.MatrixMode(GL.GL_PROJECTION);
                        GL.Translatef(+1.0f, 0.0f, 0.0f);
                        GL.MatrixMode(GL.GL_MODELVIEW);
                        break;

                    case 87:        // 'W' key pressed
                    case 119:
                        GL.MatrixMode(GL.GL_PROJECTION);
                        GL.Translatef(0.0f, +1.0f, 0.0f);
                        GL.MatrixMode(GL.GL_MODELVIEW);
                        break;

                    case 27:        // ESCAPE key pressed, so exit the program
                        RotateAroundX = false;
                        RotateAroundY = false;
                        RotateAroundZ = false;

                        FG.IdleFunc(null);
                        FG.KeyboardFunc(null);
                        FG.MouseFunc(null);
                        FG.ReshapeFunc(null);
                        FG.DestroyWindow(FG.GetWindow());
                        break;
                    }
                }
            }
        }