If you've ever played Quake on a widescreen display, you'll have noticed that while the width is correct, the top and bottom of the 3D views is cut off. You can obviously fix this by setting the value of the fov cvar to something higher (102 worked well for me), but you shouldn't have to. You'll also have noticed that the console, status bar pictures and menus are stretched. These two tutorials will resolve all of that.
The first one we're going to do is the 2D stuff, but before I even start anything...
BEGIN DISCLAIMER
Some people may feel that a wider FOV is cheating. I'm taking the viewpoint that as Quake lets you set the FOV anyway, there is no cheating involved, at least beyond what's possible with normal Quake. Server administrators should propose a protocol extension that requires servers to examine FOV settings and enforce them on clients if there are any bad feelings about this.
END DISCLAIMER
OK, down to code.
The first thing we're going to do is fix the 2D stuff, so open gl_vidnt.c and pop this function somewhere in it. Near the top is good.
Code: Select all
void Vid_SetConSize (int modewidth, int modeheight)
{
// adjust conwidth and conheight to match the mode aspect
// they should be the same aspect as the mode, with width never less than 320 and height never less than 240
vid.conheight = 240;
vid.conwidth = 240 * modewidth / modeheight;
// bring it up to 320
if (vid.conwidth < 320)
{
vid.conwidth = 320;
vid.conheight = vid.conwidth * modeheight / modewidth;
}
// set width and height
vid.width = vid.conwidth;
vid.height = vid.conheight;
}
Now we need to call this function, so go to VID_SetMode and slap it above the "window_width = DIBWidth;" line, thusly:
Code: Select all
Vid_SetConSize (DIBWidth, DIBHeight);
window_width = DIBWidth;
window_height = DIBHeight;
VID_UpdateWindowStatus ();
Code: Select all
void Draw_ConsoleBackground (int lines)
{
int y = (vid.height * 3) >> 2;
conback->width = vid.width;
conback->height = vid.height;
if (lines > y)
Draw_Pic(0, lines - vid.height, conback);
else
Draw_AlphaPic (0, lines - vid.height, conback, (float)(1.2 * lines)/y);
}
Now we need to create a cvar to allow us to control the size, so we open gl_screen.c and declare and register a cvar in the normal fashion. Let's call it "gl_consize". I assume you know how to do this already, but here we go anyway:
Code: Select all
// this one at the top with the other cvars
cvar_t gl_consize = {"gl_consize", "0.5", true};
// this one in SCR_Init with the rest of them
Cvar_RegisterVariable (&gl_consize);
Code: Select all
float oldscreensize, oldfov, oldconsize;
Code: Select all
size /= 100.0;
// bound console size
if (gl_consize.value < 0) Cvar_Set ("gl_consize", "0");
if (gl_consize.value > 1) Cvar_Set ("gl_consize", "1");
// recalculate vid.width and vid.height
vid.width = (glwidth - vid.conwidth) * gl_consize.value + vid.conwidth;
vid.height = (glheight - vid.conheight) * gl_consize.value + vid.conheight;
h = vid.height - sb_lines;
Now we go to SCR_UpdateScreen and pop this code in between the viewsize and fov checks:
Code: Select all
if (oldconsize != gl_consize.value)
{
oldconsize = gl_consize.value;
vid.recalc_refdef = true;
}
And that is that! You could clean up by removing the -conwidth and -conheight command line options, or get fancy and add a menu option to control it, but that's up to you.
Next we're going to fix the FOV in the 3D view... stay tuned...