Exemplo n.º 1
0
  /** 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;
  }
Exemplo n.º 2
0
  /*
   * ================= SCR_CalcVrect
   *
   * Sets scr_vrect, the coordinates of the rendered window =================
   */
  static void CalcVrect() {
    int size;

    // bound viewsize
    if (scr_viewsize.value < 40) ConsoleVariables.Set("viewsize", "40");
    if (scr_viewsize.value > 100) ConsoleVariables.Set("viewsize", "100");

    size = (int) scr_viewsize.value;

    scr_vrect.width = viddef.width * size / 100;
    scr_vrect.width &= ~7;

    scr_vrect.height = viddef.height * size / 100;
    scr_vrect.height &= ~1;

    scr_vrect.x = (viddef.width - scr_vrect.width) / 2;
    scr_vrect.y = (viddef.height - scr_vrect.height) / 2;
  }
Exemplo n.º 3
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);
    }
  }
Exemplo n.º 4
0
  /** R_BeginFrame */
  public final void BeginFrame(float camera_separation) {

    GlConfig.gl_state.camera_separation = camera_separation;

    /*
     * * change modes if necessary
     */
    if (GlConfig.gl_mode.modified || GlConfig.vid_fullscreen.modified) {
      // FIXME: only restart if CDS is required
      ConsoleVariable ref;

      ref = ConsoleVariables.Get("vid_ref", "lwjgl", 0);
      ref.modified = true;
    }

    if (GlConfig.gl_log.modified) {
      // GlBase.GLimp_EnableLogging((GlState.gl_log.value != 0.0f));
      GlConfig.gl_log.modified = false;
    }

    if (GlConfig.gl_log.value != 0.0f) {
      // GlBase.GLimp_LogNewFrame();
    }

    /*
     * * update 3Dfx gamma -- it is expected that a user will do a vid_restart*
     * after tweaking this value
     */
    if (GlConfig.vid_gamma.modified) {
      GlConfig.vid_gamma.modified = false;
    }

    /*
     * * go into 2D mode
     */
    GlState.gl.glViewport(0, 0, GlState.vid.width, GlState.vid.height);
    GlState.gl.glMatrixMode(Gl1Context.GL_PROJECTION);
    GlState.gl.glLoadIdentity();
    GlState.gl.glOrtho(0, GlState.vid.width, GlState.vid.height, 0, -99999, 99999);
    GlState.gl.glMatrixMode(Gl1Context.GL_MODELVIEW);
    GlState.gl.glLoadIdentity();
    GlState.gl.glDisable(Gl1Context.GL_DEPTH_TEST);
    GlState.gl.glDisable(Gl1Context.GL_CULL_FACE);
    GlState.gl.glDisable(Gl1Context.GL_BLEND);
    // gl.glEnable(GLAdapter.GL_ALPHA_TEST);
    GlState.gl.glColor4f(1, 1, 1, 1);

    /*
     * * draw buffer stuff
     */
    if (GlConfig.gl_drawbuffer.modified) {
      GlConfig.gl_drawbuffer.modified = false;

      if (GlState.camera_separation == 0 || !GlState.stereo_enabled) {
        if (GlConfig.gl_drawbuffer.string.equalsIgnoreCase("GL_FRONT"))
          GlState.gl.glDrawBuffer(Gl1Context.GL_FRONT);
        else GlState.gl.glDrawBuffer(Gl1Context.GL_BACK);
      }
    }

    /*
     * * texturemode stuff
     */
    if (GlConfig.gl_texturemode.modified) {
      Images.GL_TextureMode(GlConfig.gl_texturemode.string);
      GlConfig.gl_texturemode.modified = false;
    }

    if (GlConfig.gl_texturealphamode.modified) {
      Images.GL_TextureAlphaMode(GlConfig.gl_texturealphamode.string);
      GlConfig.gl_texturealphamode.modified = false;
    }

    if (GlConfig.gl_texturesolidmode.modified) {
      Images.GL_TextureSolidMode(GlConfig.gl_texturesolidmode.string);
      GlConfig.gl_texturesolidmode.modified = false;
    }

    /*
     * * swapinterval stuff
     */
    Misc.GL_UpdateSwapInterval();

    //
    // clear screen if desired
    //
    Entities.R_Clear();
  }
Exemplo n.º 5
0
  /*
   * ================== SCR_Init ==================
   */
  static void Init() {
    scr_viewsize = ConsoleVariables.Get("viewsize", "100", CVAR_ARCHIVE);
    scr_conspeed = ConsoleVariables.Get("scr_conspeed", "3", 0);
    scr_showturtle = ConsoleVariables.Get("scr_showturtle", "0", 0);
    scr_showpause = ConsoleVariables.Get("scr_showpause", "1", 0);
    scr_centertime = ConsoleVariables.Get("scr_centertime", "2.5", 0);
    scr_printspeed = ConsoleVariables.Get("scr_printspeed", "8", 0);
    scr_netgraph = ConsoleVariables.Get("netgraph", "1", 0);
    scr_timegraph = ConsoleVariables.Get("timegraph", "1", 0);
    scr_debuggraph = ConsoleVariables.Get("debuggraph", "1", 0);
    scr_graphheight = ConsoleVariables.Get("graphheight", "32", 0);
    scr_graphscale = ConsoleVariables.Get("graphscale", "1", 0);
    scr_graphshift = ConsoleVariables.Get("graphshift", "0", 0);
    scr_drawall = ConsoleVariables.Get("scr_drawall", "1", 0);
    fps = ConsoleVariables.Get("fps", "1", 0);

    //
    // register our commands
    //
    Commands.addCommand(
        "timerefresh",
        new ExecutableCommand() {
          public void execute() {
            TimeRefresh_f();
          }
        });
    Commands.addCommand(
        "loading",
        new ExecutableCommand() {
          public void execute() {
            Loading_f();
          }
        });
    Commands.addCommand(
        "sizeup",
        new ExecutableCommand() {
          public void execute() {
            SizeUp_f();
          }
        });
    Commands.addCommand(
        "sizedown",
        new ExecutableCommand() {
          public void execute() {
            SizeDown_f();
          }
        });
    Commands.addCommand(
        "sky",
        new ExecutableCommand() {
          public void execute() {
            Sky_f();
          }
        });

    scr_initialized = true;
  }
Exemplo n.º 6
0
 /*
  * ================= SCR_SizeDown_f
  *
  * Keybinding command =================
  */
 static void SizeDown_f() {
   ConsoleVariables.SetValue("viewsize", scr_viewsize.value - 10);
 }
Exemplo n.º 7
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();
  }