Exemplo n.º 1
0
  /** R_SetMode */
  protected boolean R_SetMode() {
    boolean fullscreen = (vid_fullscreen.value > 0.0f);

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

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

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

      // try setting it back to something safe
      if ((err = GLimp_SetMode(dim, gl_state.prev_mode, false)) != rserr_ok) {
        VID.Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - could not revert to safe mode\n");
        return false;
      }
    }
    return true;
  }
Exemplo n.º 2
0
  /** R_BeginFrame */
  protected void R_BeginFrame(float camera_separation) {

    gl_state.camera_separation = camera_separation;

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

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

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

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

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

      if ((gl_config.renderer & GL_RENDERER_VOODOO) != 0) {
        // wird erstmal nicht gebraucht

        /*
        char envbuffer[1024];
        float g;

        g = 2.00 * ( 0.8 - ( vid_gamma->value - 0.5 ) ) + 1.0F;
        Com_sprintf( envbuffer, sizeof(envbuffer), "SSTV2_GAMMA=%f", g );
        putenv( envbuffer );
        Com_sprintf( envbuffer, sizeof(envbuffer), "SST_GAMMA=%f", g );
        putenv( envbuffer );
        */
        VID.Printf(Defines.PRINT_DEVELOPER, "gamma anpassung fuer VOODOO nicht gesetzt");
      }
    }

    GLimp_BeginFrame(camera_separation);

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

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

      if (gl_state.camera_separation == 0 || !gl_state.stereo_enabled) {
        if (gl_drawbuffer.string.equalsIgnoreCase("GL_FRONT")) GL11.glDrawBuffer(GL11.GL_FRONT);
        else GL11.glDrawBuffer(GL11.GL_BACK);
      }
    }

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

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

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

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

    //
    // clear screen if desired
    //
    R_Clear();
  }