示例#1
0
        public virtual void Init()
        {
            Globals.dedicated = Cvar.Get("dedicated", "0", Qcommon.CVAR_NOSET);
            Program.Q2Dialog  = new Q2DataDialog();
            Locale.SetDefault(Locale.US);
            Program.Q2Dialog.SetVisible(true);
            string DRIVER = "lwjgl";

            Qcommon.Init(new string { "DancingQueens", "+set", "gl_mode", "4", "+set", "vid_fullscreen", "0", "+set", "vid_ref", DRIVER });
            VID.Shutdown();
            String[] names = Renderer.GetDriverNames();
            System.Diagnostics.Debug.WriteLine("Registered Drivers: " + Arrays.AsList(names));
            this.re    = Renderer.GetDriver(DRIVER);
            Globals.re = this.re;
            System.Diagnostics.Debug.WriteLine("Use driver: " + re);
            System.out_renamed.Flush();
            re.Init(0, 0);
            kbd = re.GetKeyboardHandler();
            kbd.Init();
            Cbuf.AddText("unbind t");
            Cbuf.Execute();
            Cmd.AddCommand("togglemouse", togglemouse);
            Cbuf.AddText("bind t togglemouse");
            Cbuf.Execute();
            Globals.cls.key_dest = Defines.key_game;
            Globals.cls.state    = Defines.ca_active;
            viddef = Globals.viddef;
            fov_y  = Math3D.CalcFov(fov_x, viddef.GetWidth(), viddef.GetHeight());
        }
示例#2
0
 public static void Main(string[] args)
 {
     Qcommon.Init(args);
     System.Diagnostics.Debug.WriteLine("hello!");
     GameSave.InitGame();
     GameSave.ReadGame("test/data/savegames/game.ssv");
 }
示例#3
0
        public virtual void Init()
        {
            Globals.dedicated = Cvar.Get("dedicated", "0", Qcommon.CVAR_NOSET);
            Program.Q2Dialog  = new Q2DataDialog();
            Locale.SetDefault(Locale.US);
            Program.Q2Dialog.SetVisible(true);
            string DRIVER = "jsr231";

            Qcommon.Init(new string [] { "TestRenderer", "+set", "gl_mode", "6", "+set", "vid_fullscreen", "0", "+set", "vid_ref", DRIVER });
            VID.Shutdown();
            String[] names = Renderer.GetDriverNames();
            System.Diagnostics.Debug.WriteLine("Registered Drivers: " + Arrays.AsList(names));
            this.re    = Renderer.GetDriver(DRIVER);
            Globals.re = this.re;
            System.Diagnostics.Debug.WriteLine("Use driver: " + re);
            System.out_renamed.Flush();
            re.Init(0, 0);
            kbd = re.GetKeyboardHandler();
            kbd.Init();
            Cmd.AddCommand("nexttest", nexttest);
            Cbuf.AddText("bind n nexttest");
            Cbuf.Execute();
            Globals.cls.key_dest = Defines.key_game;
            Globals.cls.state    = Defines.ca_active;
        }
示例#4
0
 public virtual void Init()
 {
     Qcommon.Init(new string { "$Id: DebugCulling.java,v 1.6 2008-03-02 14:56:21 cawe Exp $" });
     VID.Shutdown();
     this.re = Renderer.GetDriver("jogl");
     re.Init(0, 0);
     viddef = Globals.viddef;
 }
示例#5
0
        public virtual void Init()
        {
            Globals.dedicated = Cvar.Get("dedicated", "0", Qcommon.CVAR_NOSET);
            if (Globals.dedicated.value != 1F)
            {
                Program.Q2Dialog = new Q2DataDialog();
                Locale.SetDefault(Locale.US);
                Program.Q2Dialog.SetVisible(true);
            }

            Qcommon.Init(new string[] { "TestMap" });
            VID.Shutdown();
            Globals.re = this.re = Renderer.GetDriver("jsr231", true);
            re.Init(0, 0);
            Cmd.AddCommand("+tforward", forward_down);
            Cmd.AddCommand("-tforward", forward_up);
            Cbuf.AddText("bind UPARROW +tforward");
            Cbuf.Execute();
            Cmd.AddCommand("+tbackward", backward_down);
            Cmd.AddCommand("-tbackward", backward_up);
            Cbuf.AddText("bind DOWNARROW +tbackward");
            Cbuf.Execute();
            Cmd.AddCommand("+tleft", left_down);
            Cmd.AddCommand("-tleft", left_up);
            Cbuf.AddText("bind LEFTARROW +tleft");
            Cbuf.Execute();
            Cmd.AddCommand("+tright", right_down);
            Cmd.AddCommand("-tright", right_up);
            Cbuf.AddText("bind RIGHTARROW +tright");
            Cbuf.Execute();
            Cmd.AddCommand("togglemouse", togglemouse);
            Cbuf.AddText("bind t togglemouse");
            Cbuf.Execute();
            Globals.cls.key_dest = Defines.key_game;
            Globals.cls.state    = Defines.ca_active;
            viddef = Globals.viddef;
        }
示例#6
0
        public unsafe int setMode(Size dim, int mode, bool fullscreen)
        {
            var windowSize = new Size();

            VID.Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n");
            VID.Printf(Defines.PRINT_ALL, $"...setting mode {mode}:");

            if (this.oldDisplayMode == null)
            {
                GLFW.Init();
                var videoMode = GLFW.GetVideoMode(GLFW.GetPrimaryMonitor())[0];

                this.oldDisplayMode =
                    new(videoMode.Width, videoMode.Height, videoMode.RefreshRate, videoMode.RedBits + videoMode.GreenBits + videoMode.BlueBits);
            }

            if (!VID.GetModeInfo(ref windowSize, mode))
            {
                VID.Printf(Defines.PRINT_ALL, " invalid mode\n");

                return(Base.rserr_invalid_mode);
            }

            VID.Printf(Defines.PRINT_ALL, $" {windowSize.Width} {windowSize.Height}{'\n'}");

            if (this.window != null)
            {
                this.shutdown();
            }

            if (fullscreen)
            {
                var displayMode =
                    this.getModeList().FirstOrDefault(displayMode => displayMode.Width == windowSize.Width && displayMode.Height == windowSize.Height)
                    ?? this.oldDisplayMode;

                this.window = new(GameWindowSettings.Default, new()
                {
                    Profile = ContextProfile.Compatability, Size = new(displayMode.Width, displayMode.Height), IsFullscreen = true
                });

                VID.Printf(
                    Defines.PRINT_ALL,
                    $"...setting fullscreen {displayMode.Width}x{displayMode.Height}x{displayMode.BitDepth}@{displayMode.RefreshRate}Hz\n"
                    );
            }
            else
            {
                this.window = new(GameWindowSettings.Default, new()
                {
                    Profile = ContextProfile.Compatability, Size = new(windowSize.Width, windowSize.Height)
                });

                VID.Printf(Defines.PRINT_ALL, $"...setting window {windowSize.Width}x{windowSize.Height}\n");
            }

            this.window.Focus();
            this.window.Closed += OpenTkDriver.QuitOnClose;

            OpenTkKBD.Window        = this.window;
            this.window.KeyDown    += OpenTkKBD.Listener.KeyDown;
            this.window.KeyUp      += OpenTkKBD.Listener.KeyUp;
            this.window.MouseDown  += OpenTkKBD.Listener.MouseDown;
            this.window.MouseUp    += OpenTkKBD.Listener.MouseUp;
            this.window.MouseMove  += OpenTkKBD.Listener.MouseMove;
            this.window.MouseWheel += OpenTkKBD.Listener.MouseWheel;

            Program.UpdateLoop = _ => this.window.Run();

            var initialized = false;

            var updateAccumulator = 0.0;
            var renderAccumulator = 0.0;

            this.window.UpdateFrame += args =>
            {
                updateAccumulator += args.Time * 1000;

                var elapsed = (int)updateAccumulator;

                if (elapsed <= 0)
                {
                    return;
                }

                Qcommon.FrameUpdate(elapsed);
                updateAccumulator -= elapsed;
            };

            this.window.RenderFrame += args =>
            {
                if (!initialized)
                {
                    this.init(0, 0);
                    initialized = true;
                }

                renderAccumulator += args.Time * 1000;

                var elapsed = (int)renderAccumulator;

                if (elapsed <= 0)
                {
                    return;
                }

                Qcommon.FrameRender(elapsed);
                renderAccumulator -= elapsed;
            };

            this.window.Resize += args =>
            {
                Base.setVid(this.window.ClientSize.X, this.window.ClientSize.Y);
                VID.NewWindow(this.window.ClientSize.X, this.window.ClientSize.Y);
            };

            return(Base.rserr_ok);
        }
示例#7
0
        public static void Main(string[] args)
        {
            var dedicated = false;

            // check if we are in dedicated mode to hide the dialog.
            for (var n = 0; n < args.Length; n++)
            {
                if (!args[n].Equals("+set"))
                {
                    continue;
                }

                if (++n >= args.Length)
                {
                    break;
                }

                if (!args[n].Equals("dedicated"))
                {
                    continue;
                }

                if (++n >= args.Length)
                {
                    break;
                }

                if (!args[n].Equals("1") && !args[n].Equals("\"1\""))
                {
                    continue;
                }

                Com.Printf("Starting in dedicated mode.\n");
                dedicated = true;
            }

            Globals.dedicated = Cvar.Get("dedicated", "0", Defines.CVAR_NOSET);

            if (dedicated)
            {
                Globals.dedicated.value = 1.0f;
            }

            Qcommon.Init(args);

            Globals.nostdout = Cvar.Get("nostdout", "0", 0);

            while (true)
            {
                // find time spending rendering last frame
                var now   = Timer.Milliseconds();
                var delta = now - Program.last;

                if (Program.UpdateLoop != null)
                {
                    Program.UpdateLoop(delta);
                }
                else if (delta > 0)
                {
                    Qcommon.FrameUpdate(delta);
                    Qcommon.FrameRender(delta);
                }

                Program.last = now;
            }
        }