Esempio n. 1
0
        private static void Command_background(string[] parameters)
        {
            if (parameters == null || parameters.Length != 1)
            {
                ConsoleManager.WriteLine("HELP: background <imagefilename>");
            }
            else
            {
                string ImageFileName = @"data\" + parameters[0];

                if (File.Exists(ImageFileName))
                {
                    ConsoleVarManager.Set("ConsoleBackground", ImageFileName);
                    ConsoleManager.Init();
                }
                else
                {
                    ConsoleManager.WriteLine("Error! The specified background image not found!");
                }
            }
        }
Esempio n. 2
0
        // Init
        public static void Init()
        {
            if (ConsoleVarManager.GetValueToString("Q2ConsoleInit") == "true")
            {
                // Init FreeGlut
                int[] argc = new int[1]; argc[0] = 0; string[] argv = null;
                FG.Init(argc, argv);

                FG.InitDisplayMode(FG.GLUT_RGBA | FG.GLUT_DOUBLE | FG.GLUT_DEPTH);
                FG.InitWindowPosition(25, 25);
                FG.InitWindowSize(1024, 768);
                FG.InitContextVersion(2, 1);
                FG.InitContextFlags((int)FG.GLUT_FORWARD_COMPATIBLE);
                FG.InitContextProfile((int)FG.GLUT_COMPATIBILITY_PROFILE);
                int hWindow = FG.CreateWindow(ConsoleVarManager.GetValueToString("VersionLong"));

                // Setup OpenGL window and OpenGL itself
                GL.Init(true);

                // Init DevIL -> Developers Image Libary
                IL.Init();
                ILU.Init();
                ILUT.Init();
                ILUT.Renderer(ILUT.ILUT_OPENGL);
            }

            SetupGL();                  // Each time ScreenSize changes, this must be called
            ConsoleManager.Init();      // Each time ScreenSize changes, this must be called

            if (ConsoleVarManager.GetValueToString("Q2ConsoleInit") == "true")
            {
                string[] OpenGLDotNetInitLog = GLConfig.LogDumpToString();
                foreach (string Line in OpenGLDotNetInitLog)
                {
                    ConsoleManager.WriteLine(Line);
                }
            }

            if (ConsoleVarManager.GetValueToString("Q2ConsoleInit") == "true")
            {
                // We don't want to Init and Add commands each time ScreenSize changes
                CommandManager.Init();

                CommandManager.ExecuteCommand("openglinfo");
                CommandManager.ExecuteCommand("cpuinfo");
                CommandManager.ExecuteCommand("help");

                FG.IdleFunc(IdleProc);
                FG.KeyboardFunc(KeyboardProc);
                FG.MouseFunc(MouseProc);
                FG.ReshapeFunc(ReshapeProc);
                FG.DisplayFunc(DisplayProc);

                GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
                FG.SwapBuffers();

                // Before entering FG.MainLoop(), we must set the variable
                ConsoleVarManager.Set("Q2ConsoleInit", "false");

                // Enter the FG.MainLoop()
                FG.SetOption(FG.GLUT_ACTION_ON_WINDOW_CLOSE, (int)FG.GLUT_ACTION_GLUTMAINLOOP_RETURNS);
                FG.MainLoop();
            }
        }
Esempio n. 3
0
        public static void Reshape(int width, int height)
        {
            //Console.WriteLine("Reshape: {0}x{1}", width, height);

            if (width <= 0)
            {
                width = 1;
            }
            if (height <= 0)
            {
                height = 1;
            }

            ConsoleVarManager.SetOrCreate("ScreenWidth", width.ToString(), 0);
            ConsoleVarManager.SetOrCreate("ScreenHeight", height.ToString(), 0);
            ConsoleManager.Init();

            SetupGL();

            if (ConsoleManager.IsOpen)
            {
                GL.Viewport(0, 0, width, height);

                GL.MatrixMode(GL.GL_PROJECTION);
                GL.LoadIdentity();

                GL.Ortho(0, width, height, 0, -4096, 4096);

                GL.MatrixMode(GL.GL_MODELVIEW);
                GL.LoadIdentity();
            }
            else
            {
                if (ConsoleVarManager.GetValueToByte("DemoFreeglut") == 1)
                {
                    float ratio = 0;
                    float ortho = 30;

                    GL.Viewport(0, 0, width, height);

                    GL.MatrixMode(GL.GL_PROJECTION);
                    GL.LoadIdentity();

                    if (width >= height)
                    {
                        ratio = (float)width / (float)height;
                        GL.Ortho(-ortho * ratio, ortho * ratio, -ortho, ortho, -ortho, ortho);
                    }
                    else
                    {
                        ratio = (float)height / (float)width;
                        GL.Ortho(-ortho, ortho, -ortho * ratio, ortho * ratio, -ortho, ortho);
                    }

                    GL.MatrixMode(GL.GL_MODELVIEW);
                    GL.LoadIdentity();
                }

                if (ConsoleVarManager.GetValueToByte("DemoCubemapping") == 1)
                {
                    GL.Viewport(0, 0, width, height);                   // Set the viewport for the OpenGL window

                    GL.MatrixMode(GL.GL_PROJECTION);
                    GL.LoadIdentity();

                    GLU.Perspective(45.0, (float)width / (float)height, 1.0, 100.0);  // Do the perspective calculations. Last value = max clipping depth

                    GL.MatrixMode(GL.GL_MODELVIEW);
                    GL.LoadIdentity();
                }

                if (ConsoleVarManager.GetValueToByte("DemoGUI") == 1)
                {
                    GL.Viewport(0, 0, width, height);

                    GL.MatrixMode(GL.GL_PROJECTION);
                    GL.LoadIdentity();

                    GL.Ortho(0, width, height, 0, -4096, 4096);

                    GL.MatrixMode(GL.GL_MODELVIEW);
                    GL.LoadIdentity();
                }
            }
        }