diff --git a/src/gl_local.h b/src/gl_local.h index 421c4e2..e2abf18 100644 --- a/src/gl_local.h +++ b/src/gl_local.h @@ -257,6 +257,7 @@ extern int gl_tex_alpha_format; extern int c_visible_lightmaps; extern int c_visible_textures; +extern cvar_t *skydistance; /* skybox size change */ extern float r_world_matrix[16]; diff --git a/src/gl_rmain.c b/src/gl_rmain.c index ef51b13..6be60d3 100644 --- a/src/gl_rmain.c +++ b/src/gl_rmain.c @@ -143,6 +143,7 @@ cvar_t *gl_3dlabs_broken; cvar_t *vid_fullscreen; cvar_t *vid_gamma; cvar_t *vid_ref; +cvar_t *skydistance; /* ================= @@ -716,6 +717,9 @@ void R_SetupGL (void) float screenaspect; // float yfov; int x, x2, y2, y, w, h; + /* skybox vars */ + static GLdouble farz; + GLdouble boxsize; // // set up viewport @@ -730,6 +734,23 @@ void R_SetupGL (void) qglViewport (x, y2, w, h); + /* block of code for SkyBox Size change */ + if (skydistance->modified) { + skydistance->modified = false; + boxsize = skydistance->value; + boxsize -= 252 * ceil(boxsize / 2300); + farz = 1.0; + while (farz < boxsize) { /* make this value a power-of-2 */ + farz *= 2.0; + if (farz >= 65536.0) /* don't make it larger than this */ + break; + } + /* double since boxsize is distance from camera to + * edge of skybox - not total size of skybox */ + farz *= 2.0; + ri.Con_Printf(PRINT_DEVELOPER, "farz now set to %g\n", farz); + } + // // set up projection matrix // @@ -737,7 +758,7 @@ void R_SetupGL (void) // yfov = 2*atan((float)r_newrefdef.height/r_newrefdef.width)*180/M_PI; qglMatrixMode(GL_PROJECTION); qglLoadIdentity (); - MYgluPerspective (r_newrefdef.fov_y, screenaspect, 4, 4096); + MYgluPerspective(r_newrefdef.fov_y, screenaspect, 4, farz); qglCullFace(GL_FRONT); @@ -1064,6 +1085,7 @@ void R_Register( void ) vid_fullscreen = ri.Cvar_Get( "vid_fullscreen", "0", CVAR_ARCHIVE ); vid_gamma = ri.Cvar_Get( "vid_gamma", "1.0", CVAR_ARCHIVE ); vid_ref = ri.Cvar_Get( "vid_ref", "soft", CVAR_ARCHIVE ); + skydistance = ri.Cvar_Get("skydistance", "2300", CVAR_ARCHIVE); ri.Cmd_AddCommand( "imagelist", GL_ImageList_f ); ri.Cmd_AddCommand( "screenshot", GL_ScreenShot_f ); @@ -1090,7 +1112,7 @@ qboolean R_SetMode (void) } #endif fullscreen = vid_fullscreen->value; - + skydistance->modified = true; vid_fullscreen->modified = false; gl_mode->modified = false; diff --git a/src/gl_warp.c b/src/gl_warp.c index aadff6d..06be964 100644 --- a/src/gl_warp.c +++ b/src/gl_warp.c @@ -521,9 +521,9 @@ void MakeSkyVec (float s, float t, int axis) vec3_t v, b; int j, k; - b[0] = s*2300; - b[1] = t*2300; - b[2] = 2300; + b[0] = s * skydistance->value; + b[1] = t * skydistance->value; + b[2] = skydistance->value; for (j=0 ; j<3 ; j++) {