Esempio n. 1
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);
    }
  }
Esempio n. 2
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();
  }