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_Init */
  protected boolean R_Init(int vid_xpos, int vid_ypos) {

    assert (Warp.SIN.length == 256) : "warpsin table bug";

    // fill r_turbsin
    for (int j = 0; j < 256; j++) {
      r_turbsin[j] = Warp.SIN[j] * 0.5f;
    }

    VID.Printf(Defines.PRINT_ALL, "ref_gl version: " + REF_VERSION + '\n');

    Draw_GetPalette();

    R_Register();

    // set our "safe" modes
    gl_state.prev_mode = 3;

    // create the window and set up the context
    if (!R_SetMode()) {
      VID.Printf(Defines.PRINT_ALL, "ref_gl::R_Init() - could not R_SetMode()\n");
      return false;
    }
    return true;
  }
Esempio n. 3
0
  /** R_RenderView r_newrefdef must be set before the first call */
  void R_RenderView(refdef_t fd) {

    if (r_norefresh.value != 0.0f) return;

    r_newrefdef = fd;

    // included by cwei
    if (r_newrefdef == null) {
      Com.Error(Defines.ERR_DROP, "R_RenderView: refdef_t fd is null");
    }

    if (r_worldmodel == null && (r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0)
      Com.Error(Defines.ERR_DROP, "R_RenderView: NULL worldmodel");

    if (r_speeds.value != 0.0f) {
      c_brush_polys = 0;
      c_alias_polys = 0;
    }

    R_PushDlights();

    if (gl_finish.value != 0.0f) GL11.glFinish();

    R_SetupFrame();

    R_SetFrustum();

    R_SetupGL();

    R_MarkLeaves(); // done here so we know if we're in water

    R_DrawWorld();

    R_DrawEntitiesOnList();

    R_RenderDlights();

    R_DrawParticles();

    R_DrawAlphaSurfaces();

    R_Flash();

    if (r_speeds.value != 0.0f) {
      VID.Printf(
          Defines.PRINT_ALL,
          "%4i wpoly %4i epoly %i tex %i lmaps\n",
          new Vargs(4)
              .add(c_brush_polys)
              .add(c_alias_polys)
              .add(c_visible_textures)
              .add(c_visible_lightmaps));
    }
  }
Esempio n. 4
0
  /** @see jake2.client.refexport_t#Init() */
  public boolean Init(int vid_xpos, int vid_ypos) {

    // pre init
    if (!R_Init(vid_xpos, vid_ypos)) return false;
    // post init
    boolean ok = R_Init2();
    if (!ok) {
      VID.Printf(Defines.PRINT_ALL, "Missing multi-texturing for LWJGL renderer\n");
    }
    return ok;
  }
Esempio n. 5
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. 6
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;
  }