Пример #1
0
        /// <summary>
        /// GL_EndRendering
        /// </summary>
        public static void EndRendering()
        {
            mainwindow form = mainwindow.Instance;

            if (form == null)
            {
                return;
            }

            if (!SkipUpdate || BlockDrawing)
            {
                form.SwapBuffers();
            }

            // handle the mouse state
            if (!SharpQuake.vid.WindowedMouse)
            {
                if (_IsMouseWindowed)
                {
                    input.DeactivateMouse();
                    input.ShowMouse();
                    _IsMouseWindowed = false;
                }
            }
            else
            {
                _IsMouseWindowed = true;
                if (Key.Destination == keydest_t.key_game && !input.IsMouseActive &&
                    client.cls.state != cactive_t.ca_disconnected) // && ActiveApp)
                {
                    input.ActivateMouse();
                    input.HideMouse();
                }
                else if (input.IsMouseActive && Key.Destination != keydest_t.key_game)
                {
                    input.DeactivateMouse();
                    input.ShowMouse();
                }
            }

            if (FullSbarDraw)
            {
                sbar.Changed();
            }
        }
Пример #2
0
        // VID_SetMode (int modenum, unsigned char *palette)
        // sets the mode; only used by the Quake engine for resetting to mode 0 (the
        // base mode) on memory allocation failures
        public static void SetMode(int modenum, byte[] palette)
        {
            if (modenum < 0 || modenum >= _Modes.Length)
            {
                sys.Error("Bad video mode\n");
            }

            mode_t mode = _Modes[modenum];

            // so Con_Printfs don't mess us up by forcing vid and snd updates
            bool temp = Scr.IsDisabledForLoading;

            Scr.IsDisabledForLoading = true;

            cd_audio.Pause();

            // Set either the fullscreen or windowed mode
            DisplayDevice dev  = mainwindow.DisplayDevice;
            mainwindow    form = mainwindow.Instance;

            if (_Windowed)
            {
                try
                {
                    dev.ChangeResolution(mode.width, mode.height, mode.bpp, mode.refreshRate);
                }
                catch (Exception ex)
                {
                    sys.Error("Couldn't set video mode: " + ex.Message);
                }
                form.WindowState  = WindowState.Normal;
                form.WindowBorder = WindowBorder.Fixed;

                /*form.WindowState = WindowState.Normal;
                 * form.WindowBorder = WindowBorder.Fixed;
                 * form.Location = new Point( ( mode.width - form.Width ) / 2, ( mode.height - form.Height ) / 2 );
                 * if( _WindowedMouse.Value != 0 && Key.Destination == keydest_t.key_game )
                 * {
                 *  Input.ActivateMouse();
                 *  Input.HideMouse();
                 * }
                 * else
                 * {
                 *  Input.DeactivateMouse();
                 *  Input.ShowMouse();
                 * }*/
            }
            else
            {
                try
                {
                    dev.ChangeResolution(mode.width, mode.height, mode.bpp, mode.refreshRate);
                }
                catch (Exception ex)
                {
                    sys.Error("Couldn't set video mode: " + ex.Message);
                }
                form.WindowState  = WindowState.Fullscreen;
                form.WindowBorder = WindowBorder.Hidden;
            }

            viddef_t vid = Scr.vid;

            if (vid.conheight > dev.Height)
            {
                vid.conheight = dev.Height;
            }
            if (vid.conwidth > dev.Width)
            {
                vid.conwidth = dev.Width;
            }

            vid.width  = vid.conwidth;
            vid.height = vid.conheight;

            vid.numpages = 2;

            cd_audio.Resume();
            Scr.IsDisabledForLoading = temp;

            _ModeNum = modenum;
            cvar.Set("vid_mode", (float)_ModeNum);

            // fix the leftover Alt from any Alt-Tab or the like that switched us away
            ClearAllStates();

            Con.SafePrint("Video mode {0} initialized.\n", GetModeDescription(_ModeNum));

            SetPalette(palette);

            vid.recalc_refdef = true;
        }
Пример #3
0
        private static int Main(string[] args)
        {
            //Workaround for SDL2 mouse input issues
            var options = new ToolkitOptions();

            options.Backend = PlatformBackend.PreferNative;
            options.EnableHighResolution = true; //Just for testing
            Toolkit.Init(options);
#if !DEBUG
            try
            {
#endif
            // select display device
            _DisplayDevice = DisplayDevice.Default;

            if (File.Exists(DumpFilePath))
            {
                File.Delete(DumpFilePath);
            }

            quakeparms_t parms = new quakeparms_t();

            parms.basedir = AppDomain.CurrentDomain.BaseDirectory; //Application.StartupPath;

            string[] args2 = new string[args.Length + 1];
            args2[0] = String.Empty;
            args.CopyTo(args2, 1);

            common.InitArgv(args2);

            parms.argv = new string[common.Argc];
            common.Args.CopyTo(parms.argv, 0);

            if (common.HasParam("-dedicated"))
            {
                throw new QuakeException("Dedicated server mode not supported!");
            }

            Size size         = new Size(1280, 720);
            GraphicsMode mode = new GraphicsMode();
            using (mainwindow form = mainwindow.CreateInstance(size, mode, false))
            {
                Con.DPrint("Host.Init\n");
                host.Init(parms);
                Instance.CursorVisible = false; //Hides mouse cursor during main menu on start up
                form.Run();
            }
            host.Shutdown();
#if !DEBUG
        }

        catch (QuakeSystemError se)
        {
            HandleException(se);
        }
        catch (Exception ex)
        {
            HandleException(ex);
        }
#endif
            return(0); // all Ok
        }