[quake2] Quake2 skydistance patch

brendanburns at comcast.net brendanburns at comcast.net
Thu Aug 25 19:23:06 EDT 2005


Hey,
Thanks for the patch, it has been added to CVS.  I modified the skybox computation as follows:

if (skydistance->modified)
	 {
	   skydistance->modified = false;
	   boxsize = skydistance->value;
	   boxsize -= 252 * ceil(boxsize / 2300);
	   farz = pow(2,floor(log(boxsize))+1);
	   ri.Con_Printf(PRINT_DEVELOPER, "farz now set to %g\n", farz);
	 }

I'm pretty much positive that's identical and faster...

--brendan


> Hi all,
> 
> Yonks ago when I was a poor windows user, I added this hack as I used to play 
> Quake2 DDay, which has very big maps:
> 
> http://www.quakesrc.org/tutorials/old/31
> 
> Anyway, since then I moved to Linux and use the great icculus build with 
> SDL_GL.  I started playing a map (The Longest Three Feet, quake3 converted to 
> Quake2) map - this is a big map, so I missed the skydistance CVAR a lot.
> 
> I have just added to icculus build quake2-r0.16.1 - attached are the patch 
> files to add the skydistance CVAR and code if you wish to add.   It works 
> well in SDL.
> 
> Nick
> -- 
> "When you're chewing on life's gristle,
> Don't grumble, Give a whistle..."
> --- gl_local.hORIG	2005-08-25 20:11:37.000000000 +0100
> +++ gl_local.h	2005-08-25 19:44:56.000000000 +0100
> @@ -247,6 +247,9 @@
>  
>  extern	cvar_t		*intensity;
>  
> +// Nick - 25/08/2005 - skydistance
> +extern cvar_t *skydistance; // DMP - skybox size change
> +
>  extern	int		gl_lightmap_format;
>  extern	int		gl_solid_format;
>  extern	int		gl_alpha_format;
> --- gl_rmain.cORIG	2005-08-25 20:11:20.000000000 +0100
> +++ gl_rmain.c	2005-08-25 19:56:34.000000000 +0100
> @@ -135,6 +135,8 @@
>  cvar_t	*vid_fullscreen;
>  cvar_t	*vid_gamma;
>  cvar_t	*vid_ref;
> +// Nick - 25/08/2005 - skydistance
> +cvar_t *skydistance; // DMP - skybox size change
>  
>  /*
>  =================
> @@ -702,6 +704,9 @@
>  	float	screenaspect;
>  //	float	yfov;
>  	int		x, x2, y2, y, w, h;
> +// Nick - 25/08/2005 - skydistance
> +	static GLdouble farz; // DMP skybox size change
> +	GLdouble boxsize;  // DMP skybox size change
>  
>  	//
>  	// set up viewport
> @@ -716,6 +721,31 @@
>  
>  	qglViewport (x, y2, w, h);
>  
> +// Nick - 25/08/2005 - skydistance
> +// DMP: calc farz value from skybox size
> +
> +	if (skydistance->modified)
> +
> +	{
> +
> +        	skydistance->modified = false;
> +        	boxsize = skydistance->value;
> +        	boxsize -= 252 * ceil(boxsize / 2300);
> +        	farz = 1.0;
> +
> +        		while (farz < boxsize)  // DMP: make this value a 
> power-of-2
> +        		{
> +                		farz *= 2.0;
> +                		if (farz >= 65536.0)  // DMP: don't make it 
> larger than this
> +                        	break;
> +        		}
> +        	farz *= 2.0;    // DMP: double since boxsize is distance from 
> camera to
> +                // edge of skybox - not total size of skybox
> +        	ri.Con_Printf(PRINT_DEVELOPER, "farz now set to %g\n", farz);
> +	}
> +// End Nick
> +
> +
>  	//
>  	// set up projection matrix
>  	//
> @@ -723,7 +753,10 @@
>  //	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);
> +
> +// Nick 25/08/2005 - skydistance
> +//    MYgluPerspective (r_newrefdef.fov_y,  screenaspect,  4,  4096);
> +	MYgluPerspective (r_newrefdef.fov_y,  screenaspect, 4, farz); // DMP 
> skybox
>  
>  	qglCullFace(GL_FRONT);
>  
> @@ -1049,8 +1082,12 @@
>  	gl_3dlabs_broken = ri.Cvar_Get( "gl_3dlabs_broken", "1", CVAR_ARCHIVE );
>  
>  	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 );
> +// Nick - 25/08/2005 - skydistance
> +	skydistance = ri.Cvar_Get("skydistance", "2300", 0); // DMP - skybox 
> size change
> +
>  
>  	ri.Cmd_AddCommand( "imagelist", GL_ImageList_f );
>  	ri.Cmd_AddCommand( "screenshot", GL_ScreenShot_f );
> @@ -1077,6 +1114,9 @@
>  	}
>  #endif
>  	fullscreen = vid_fullscreen->value;
> +// Nick - 25/08/2005 - skydistance
> +	skydistance->modified = true; // DMP skybox size change
> +
>  
>  	vid_fullscreen->modified = false;
>  	gl_mode->modified = false;
> --- gl_warp.cORIG	2005-08-25 20:10:59.000000000 +0100
> +++ gl_warp.c	2005-08-25 19:58:53.000000000 +0100
> @@ -522,9 +522,16 @@
>  	vec3_t		v, b;
>  	int			j, k;
>  
> +/* Nick - 25/08/2005 - skydistance
> +
>  	b[0] = s*2300;
>  	b[1] = t*2300;
>  	b[2] = 2300;
> +*/
> +        b[0] = s * skydistance->value; // DMP skybox size changes
> +        b[1] = t * skydistance->value; // DMP
> +        b[2] = skydistance->value;  // DMP
> +// End Nick
>  
>  	for (j=0 ; j<3 ; j++)
>  	{



More information about the quake2 mailing list