Esempio 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;
  }
Esempio 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();
  }
Esempio n. 3
0
  /** R_Register */
  protected void R_Register() {
    r_lefthand = Cvar.Get("hand", "0", Globals.CVAR_USERINFO | Globals.CVAR_ARCHIVE);
    r_norefresh = Cvar.Get("r_norefresh", "0", 0);
    r_fullbright = Cvar.Get("r_fullbright", "0", 0);
    r_drawentities = Cvar.Get("r_drawentities", "1", 0);
    r_drawworld = Cvar.Get("r_drawworld", "1", 0);
    r_novis = Cvar.Get("r_novis", "0", 0);
    r_nocull = Cvar.Get("r_nocull", "0", 0);
    r_lerpmodels = Cvar.Get("r_lerpmodels", "1", 0);
    r_speeds = Cvar.Get("r_speeds", "0", 0);

    r_lightlevel = Cvar.Get("r_lightlevel", "1", 0);

    gl_nosubimage = Cvar.Get("gl_nosubimage", "0", 0);
    gl_allow_software = Cvar.Get("gl_allow_software", "0", 0);

    gl_particle_min_size = Cvar.Get("gl_particle_min_size", "2", Globals.CVAR_ARCHIVE);
    gl_particle_max_size = Cvar.Get("gl_particle_max_size", "40", Globals.CVAR_ARCHIVE);
    gl_particle_size = Cvar.Get("gl_particle_size", "40", Globals.CVAR_ARCHIVE);
    gl_particle_att_a = Cvar.Get("gl_particle_att_a", "0.01", Globals.CVAR_ARCHIVE);
    gl_particle_att_b = Cvar.Get("gl_particle_att_b", "0.0", Globals.CVAR_ARCHIVE);
    gl_particle_att_c = Cvar.Get("gl_particle_att_c", "0.01", Globals.CVAR_ARCHIVE);

    gl_modulate = Cvar.Get("gl_modulate", "1.5", Globals.CVAR_ARCHIVE);
    gl_log = Cvar.Get("gl_log", "0", 0);
    gl_bitdepth = Cvar.Get("gl_bitdepth", "0", 0);
    gl_mode = Cvar.Get("gl_mode", "3", Globals.CVAR_ARCHIVE); // 640x480
    gl_lightmap = Cvar.Get("gl_lightmap", "0", 0);
    gl_shadows = Cvar.Get("gl_shadows", "0", Globals.CVAR_ARCHIVE);
    gl_dynamic = Cvar.Get("gl_dynamic", "1", 0);
    gl_nobind = Cvar.Get("gl_nobind", "0", 0);
    gl_round_down = Cvar.Get("gl_round_down", "1", 0);
    gl_picmip = Cvar.Get("gl_picmip", "0", 0);
    gl_skymip = Cvar.Get("gl_skymip", "0", 0);
    gl_showtris = Cvar.Get("gl_showtris", "0", 0);
    gl_ztrick = Cvar.Get("gl_ztrick", "0", 0);
    gl_finish = Cvar.Get("gl_finish", "0", Globals.CVAR_ARCHIVE);
    gl_clear = Cvar.Get("gl_clear", "0", 0);
    gl_cull = Cvar.Get("gl_cull", "1", 0);
    gl_polyblend = Cvar.Get("gl_polyblend", "1", 0);
    gl_flashblend = Cvar.Get("gl_flashblend", "0", 0);
    gl_playermip = Cvar.Get("gl_playermip", "0", 0);
    gl_monolightmap = Cvar.Get("gl_monolightmap", "0", 0);
    gl_driver = Cvar.Get("gl_driver", "opengl32", Globals.CVAR_ARCHIVE);
    gl_texturemode = Cvar.Get("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", Globals.CVAR_ARCHIVE);
    gl_texturealphamode = Cvar.Get("gl_texturealphamode", "default", Globals.CVAR_ARCHIVE);
    gl_texturesolidmode = Cvar.Get("gl_texturesolidmode", "default", Globals.CVAR_ARCHIVE);
    gl_lockpvs = Cvar.Get("gl_lockpvs", "0", 0);

    gl_vertex_arrays = Cvar.Get("gl_vertex_arrays", "1", Globals.CVAR_ARCHIVE);

    gl_ext_swapinterval = Cvar.Get("gl_ext_swapinterval", "1", Globals.CVAR_ARCHIVE);
    gl_ext_palettedtexture = Cvar.Get("gl_ext_palettedtexture", "0", Globals.CVAR_ARCHIVE);
    gl_ext_multitexture = Cvar.Get("gl_ext_multitexture", "1", Globals.CVAR_ARCHIVE);
    gl_ext_pointparameters = Cvar.Get("gl_ext_pointparameters", "1", Globals.CVAR_ARCHIVE);
    gl_ext_compiled_vertex_array =
        Cvar.Get("gl_ext_compiled_vertex_array", "1", Globals.CVAR_ARCHIVE);

    gl_drawbuffer = Cvar.Get("gl_drawbuffer", "GL_BACK", 0);
    gl_swapinterval = Cvar.Get("gl_swapinterval", "0", Globals.CVAR_ARCHIVE);

    gl_saturatelighting = Cvar.Get("gl_saturatelighting", "0", 0);

    gl_3dlabs_broken = Cvar.Get("gl_3dlabs_broken", "1", Globals.CVAR_ARCHIVE);

    vid_fullscreen = Cvar.Get("vid_fullscreen", "0", Globals.CVAR_ARCHIVE);
    vid_gamma = Cvar.Get("vid_gamma", "1.0", Globals.CVAR_ARCHIVE);
    vid_ref = Cvar.Get("vid_ref", "lwjgl", Globals.CVAR_ARCHIVE);

    Cmd.AddCommand(
        "imagelist",
        new xcommand_t() {
          public void execute() {
            GL_ImageList_f();
          }
        });

    Cmd.AddCommand(
        "screenshot",
        new xcommand_t() {
          public void execute() {
            GL_ScreenShot_f();
          }
        });
    Cmd.AddCommand(
        "modellist",
        new xcommand_t() {
          public void execute() {
            Mod_Modellist_f();
          }
        });
    Cmd.AddCommand(
        "gl_strings",
        new xcommand_t() {
          public void execute() {
            GL_Strings_f();
          }
        });
  }
Esempio n. 4
0
  /** R_Init2 */
  protected boolean R_Init2() {
    VID.MenuInit();

    /*
     ** get our various GL strings
     */
    gl_config.vendor_string = GL11.glGetString(GL11.GL_VENDOR);
    VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n');
    gl_config.renderer_string = GL11.glGetString(GL11.GL_RENDERER);
    VID.Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n');
    gl_config.version_string = GL11.glGetString(GL11.GL_VERSION);
    VID.Printf(Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n');
    gl_config.extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS);
    VID.Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n');

    gl_config.parseOpenGLVersion();

    String renderer_buffer = gl_config.renderer_string.toLowerCase();
    String vendor_buffer = gl_config.vendor_string.toLowerCase();

    if (renderer_buffer.indexOf("voodoo") >= 0) {
      if (renderer_buffer.indexOf("rush") < 0) gl_config.renderer = GL_RENDERER_VOODOO;
      else gl_config.renderer = GL_RENDERER_VOODOO_RUSH;
    } else if (vendor_buffer.indexOf("sgi") >= 0) gl_config.renderer = GL_RENDERER_SGI;
    else if (renderer_buffer.indexOf("permedia") >= 0) gl_config.renderer = GL_RENDERER_PERMEDIA2;
    else if (renderer_buffer.indexOf("glint") >= 0) gl_config.renderer = GL_RENDERER_GLINT_MX;
    else if (renderer_buffer.indexOf("glzicd") >= 0) gl_config.renderer = GL_RENDERER_REALIZM;
    else if (renderer_buffer.indexOf("gdi") >= 0) gl_config.renderer = GL_RENDERER_MCD;
    else if (renderer_buffer.indexOf("pcx2") >= 0) gl_config.renderer = GL_RENDERER_PCX2;
    else if (renderer_buffer.indexOf("verite") >= 0) gl_config.renderer = GL_RENDERER_RENDITION;
    else gl_config.renderer = GL_RENDERER_OTHER;

    String monolightmap = gl_monolightmap.string.toUpperCase();
    if (monolightmap.length() < 2 || monolightmap.charAt(1) != 'F') {
      if (gl_config.renderer == GL_RENDERER_PERMEDIA2) {
        Cvar.Set("gl_monolightmap", "A");
        VID.Printf(Defines.PRINT_ALL, "...using gl_monolightmap 'a'\n");
      } else if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) {
        Cvar.Set("gl_monolightmap", "0");
      } else {
        Cvar.Set("gl_monolightmap", "0");
      }
    }

    // power vr can't have anything stay in the framebuffer, so
    // the screen needs to redraw the tiled background every frame
    if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) {
      Cvar.Set("scr_drawall", "1");
    } else {
      Cvar.Set("scr_drawall", "0");
    }

    // MCD has buffering issues
    if (gl_config.renderer == GL_RENDERER_MCD) {
      Cvar.SetValue("gl_finish", 1);
    }

    if ((gl_config.renderer & GL_RENDERER_3DLABS) != 0) {
      if (gl_3dlabs_broken.value != 0.0f) gl_config.allow_cds = false;
      else gl_config.allow_cds = true;
    } else {
      gl_config.allow_cds = true;
    }

    if (gl_config.allow_cds) VID.Printf(Defines.PRINT_ALL, "...allowing CDS\n");
    else VID.Printf(Defines.PRINT_ALL, "...disabling CDS\n");

    /*
     ** grab extensions
     */
    if (gl_config.extensions_string.indexOf("GL_EXT_compiled_vertex_array") >= 0
        || gl_config.extensions_string.indexOf("GL_SGI_compiled_vertex_array") >= 0) {
      VID.Printf(Defines.PRINT_ALL, "...enabling GL_EXT_compiled_vertex_array\n");
      //		 qglLockArraysEXT = ( void * ) qwglGetProcAddress( "glLockArraysEXT" );
      if (gl_ext_compiled_vertex_array.value != 0.0f) qglLockArraysEXT = true;
      else qglLockArraysEXT = false;
      //		 qglUnlockArraysEXT = ( void * ) qwglGetProcAddress( "glUnlockArraysEXT" );
      // qglUnlockArraysEXT = true;
    } else {
      VID.Printf(Defines.PRINT_ALL, "...GL_EXT_compiled_vertex_array not found\n");
      qglLockArraysEXT = false;
    }

    if (gl_config.extensions_string.indexOf("WGL_EXT_swap_control") >= 0) {
      qwglSwapIntervalEXT = true;
      VID.Printf(Defines.PRINT_ALL, "...enabling WGL_EXT_swap_control\n");
    } else {
      qwglSwapIntervalEXT = false;
      VID.Printf(Defines.PRINT_ALL, "...WGL_EXT_swap_control not found\n");
    }

    if (gl_config.extensions_string.indexOf("GL_EXT_point_parameters") >= 0) {
      if (gl_ext_pointparameters.value != 0.0f) {
        //			 qglPointParameterfEXT = ( void (APIENTRY *)( GLenum, GLfloat ) ) qwglGetProcAddress(
        // "glPointParameterfEXT" );
        qglPointParameterfEXT = true;
        //			 qglPointParameterfvEXT = ( void (APIENTRY *)( GLenum, const GLfloat * ) )
        // qwglGetProcAddress( "glPointParameterfvEXT" );
        VID.Printf(Defines.PRINT_ALL, "...using GL_EXT_point_parameters\n");
      } else {
        VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_point_parameters\n");
      }
    } else {
      VID.Printf(Defines.PRINT_ALL, "...GL_EXT_point_parameters not found\n");
    }

    // #ifdef __linux__
    //	 if ( strstr( gl_config.extensions_string, "3DFX_set_global_palette" ))
    //	 {
    //		 if ( gl_ext_palettedtexture->value )
    //		 {
    //			 VID.Printf( Defines.PRINT_ALL, "...using 3DFX_set_global_palette\n" );
    //			 qgl3DfxSetPaletteEXT = ( void ( APIENTRY * ) (GLuint *) )qwglGetProcAddress(
    // "gl3DfxSetPaletteEXT" );
    ////			 qglColorTableEXT = Fake_glColorTableEXT;
    //		 }
    //		 else
    //		 {
    //			 VID.Printf( Defines.PRINT_ALL, "...ignoring 3DFX_set_global_palette\n" );
    //		 }
    //	 }
    //	 else
    //	 {
    //		 VID.Printf( Defines.PRINT_ALL, "...3DFX_set_global_palette not found\n" );
    //	 }
    // #endif

    if (!qglColorTableEXT
        && gl_config.extensions_string.indexOf("GL_EXT_paletted_texture") >= 0
        && gl_config.extensions_string.indexOf("GL_EXT_shared_texture_palette") >= 0) {
      if (gl_ext_palettedtexture.value != 0.0f) {
        VID.Printf(Defines.PRINT_ALL, "...using GL_EXT_shared_texture_palette\n");
        qglColorTableEXT = false; // true; TODO jogl bug
      } else {
        VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n");
        qglColorTableEXT = false;
      }
    } else {
      VID.Printf(Defines.PRINT_ALL, "...GL_EXT_shared_texture_palette not found\n");
    }

    if (gl_config.extensions_string.indexOf("GL_ARB_multitexture") >= 0) {
      VID.Printf(Defines.PRINT_ALL, "...using GL_ARB_multitexture\n");
      qglActiveTextureARB = true;
      GL_TEXTURE0 = ARBMultitexture.GL_TEXTURE0_ARB;
      GL_TEXTURE1 = ARBMultitexture.GL_TEXTURE1_ARB;
    } else {
      VID.Printf(Defines.PRINT_ALL, "...GL_ARB_multitexture not found\n");
    }

    if (!(qglActiveTextureARB)) return false;

    GL_SetDefaultState();

    GL_InitImages();
    Mod_Init();
    R_InitParticleTexture();
    Draw_InitLocal();

    int err = GL11.glGetError();
    if (err != GL11.GL_NO_ERROR)
      VID.Printf(
          Defines.PRINT_ALL,
          "glGetError() = 0x%x\n\t%s\n",
          new Vargs(2).add(err).add("" + GL11.glGetString(err)));

    return true;
  }