/** R_SetMode */
  protected boolean R_SetMode() {
    boolean fullscreen = (GlConfig.vid_fullscreen.value > 0.0f);

    GlConfig.vid_fullscreen.modified = false;
    GlConfig.gl_mode.modified = false;

    Dimension dim = new Dimension(GlState.vid.width, GlState.vid.height);

    int err; // enum rserr_t
    if ((err = GLimp_SetMode(dim, (int) GlConfig.gl_mode.value, fullscreen))
        == GlConstants.rserr_ok) {
      GlConfig.gl_state.prev_mode = (int) GlConfig.gl_mode.value;
    } else {
      if (err == GlConstants.rserr_invalid_fullscreen) {
        ConsoleVariables.SetValue("vid_fullscreen", 0);
        GlConfig.vid_fullscreen.modified = false;
        Window.Printf(
            Constants.PRINT_ALL, "ref_gl::R_SetMode() - fullscreen unavailable in this mode\n");
        if ((err = GLimp_SetMode(dim, (int) GlConfig.gl_mode.value, false)) == GlConstants.rserr_ok)
          return true;
      } else if (err == GlConstants.rserr_invalid_mode) {
        ConsoleVariables.SetValue("gl_mode", GlConfig.gl_state.prev_mode);
        GlConfig.gl_mode.modified = false;
        Window.Printf(Constants.PRINT_ALL, "ref_gl::R_SetMode() - invalid mode\n");
      }

      // try setting it back to something safe
      if ((err = GLimp_SetMode(dim, GlConfig.gl_state.prev_mode, false)) != GlConstants.rserr_ok) {
        Window.Printf(Constants.PRINT_ALL, "ref_gl::R_SetMode() - could not revert to safe mode\n");
        return false;
      }
    }
    return true;
  }
Beispiel #2
0
  static void DrawFPS() {
    if (fps.value > 0.0f) {
      if (fps.modified) {
        fps.modified = false;
        ConsoleVariables.SetValue("cl_maxfps", 1000);
      }

      int diff = cls.realtime - lasttime;
      if (diff > (int) (fps.value * 1000)) {
        fpsvalue = (cls.framecount - lastframes) * 100000 / diff / 100.0f + " fps";
        lastframes = cls.framecount;
        lasttime = cls.realtime;
      }
      int x = viddef.width - 8 * fpsvalue.length() - 2;
      re.DrawString(x, 2, fpsvalue);
    } else if (fps.modified) {
      fps.modified = false;
      ConsoleVariables.SetValue("cl_maxfps", 90);
    }
  }
Beispiel #3
0
 /*
  * ================= SCR_SizeDown_f
  *
  * Keybinding command =================
  */
 static void SizeDown_f() {
   ConsoleVariables.SetValue("viewsize", scr_viewsize.value - 10);
 }
Beispiel #4
0
  public static void UpdateScreen2() {
    int numframes;
    int i;
    // if the screen is disabled (loading plaque is up, or vid mode
    // changing)
    // do nothing at all
    if (cls.disable_screen != 0) {
      if (Timer.Milliseconds() - cls.disable_screen > 120000) {
        cls.disable_screen = 0;
        Com.Printf("Loading plaque timed out.\n");
      }
      DrawConsole();
      DrawLoading();
      return;
    }

    if (!scr_initialized || !con.initialized) return; // not initialized yet

    /*
     * * range check cl_camera_separation so we don't inadvertently fry
     * someone's * brain
     */
    if (cl_stereo_separation.value > 1.0) ConsoleVariables.SetValue("cl_stereo_separation", 1.0f);
    else if (cl_stereo_separation.value < 0)
      ConsoleVariables.SetValue("cl_stereo_separation", 0.0f);

    if (cl_stereo.value != 0) {
      numframes = 2;
      separation[0] = -cl_stereo_separation.value / 2;
      separation[1] = cl_stereo_separation.value / 2;
    } else {
      separation[0] = 0;
      separation[1] = 0;
      numframes = 1;
    }

    for (i = 0; i < numframes; i++) {
      re.BeginFrame(separation[i]);

      if (scr_draw_loading == 2) { //  loading plaque over black screen
        Dimension dim = new Dimension();

        re.CinematicSetPalette(null);
        scr_draw_loading = 0; // false
        re.DrawGetPicSize(dim, "loading");
        re.DrawPic((viddef.width - dim.width) / 2, (viddef.height - dim.height) / 2, "loading");
      }
      // if a cinematic is supposed to be running, handle menus
      // and console specially
      else if (cl.cinematictime > 0) {
        if (cls.key_dest == key_menu) {
          if (cl.cinematicpalette_active) {
            re.CinematicSetPalette(null);
            cl.cinematicpalette_active = false;
          }
          Menu.Draw();
        } else if (cls.key_dest == key_console) {
          if (cl.cinematicpalette_active) {
            re.CinematicSetPalette(null);
            cl.cinematicpalette_active = false;
          }
          DrawConsole();
        } else {
          DrawCinematic();
        }
      } else if (ResourceLoader.Pump()) {
        TileClear();
        DrawStats();
        CheckDrawCenterString();
        DrawPause();
        DrawConsole();
        Menu.Draw();
        DrawLoading();
      } else {
        // make sure the game palette is active
        if (cl.cinematicpalette_active) {
          re.CinematicSetPalette(null);
          cl.cinematicpalette_active = false;
        }
        // do 3D refresh drawing, and then update the screen
        CalcVrect();

        // clear any dirty part of the background
        TileClear();

        Video.RenderView(separation[i]);

        DrawStats();

        if ((cl.frame.playerstate.stats[STAT_LAYOUTS] & 1) != 0) DrawLayout();
        if ((cl.frame.playerstate.stats[STAT_LAYOUTS] & 2) != 0) ClientInventory.DrawInventory();

        DrawNet();
        CheckDrawCenterString();
        DrawFPS();

        //
        //				if (scr_timegraph->value)
        //					SCR_DebugGraph (cls.frametime*300, 0);
        //
        //				if (scr_debuggraph->value || scr_timegraph->value ||
        // scr_netgraph->value)
        //					SCR_DrawDebugGraph ();
        //
        DrawPause();
        DrawConsole();
        Menu.Draw();
        DrawLoading();
      }
    }

    Globals.re.EndFrame();
  }