Texture quality slider in video setup

git-svn-id: https://svn.eduke32.com/eduke32@916 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2008-07-29 05:43:47 +00:00
parent 424f02f809
commit 0faa6b0010
6 changed files with 168 additions and 127 deletions

View file

@ -553,6 +553,7 @@ extern int r_parallaxskyclamping;
extern int r_parallaxskypanning;
extern int r_cullobstructedmodels;
extern int r_fullbrights;
extern int r_downsize;
extern int mdtims, omdtims;
#endif

View file

@ -590,7 +590,9 @@ int mdloadskin_trytexcache(char *fn, int len, int pal, char effect, texcachehead
head->xdim = B_LITTLE32(head->xdim);
head->ydim = B_LITTLE32(head->ydim);
head->flags = B_LITTLE32(head->flags);
head->quality = B_LITTLE32(head->quality);
if (head->quality != r_downsize) goto failure;
if (gltexmaxsize && (head->xdim > (1<<gltexmaxsize) || head->ydim > (1<<gltexmaxsize))) goto failure;
if (!glinfo.texnpot && (head->flags & 1)) goto failure;
@ -795,7 +797,7 @@ int mdloadskin(md2model *m, int number, int pal, int surf)
if (glinfo.texcompr && glusetexcompr) intexfmt = hasalpha ? GL_COMPRESSED_RGBA_ARB : GL_COMPRESSED_RGB_ARB;
else if (!hasalpha) intexfmt = GL_RGB;
if (glinfo.bgra) texfmt = GL_BGRA;
uploadtexture((doalloc&1), xsiz, ysiz, intexfmt, texfmt, (coltype*)fptr, xsiz, ysiz, 0);
uploadtexture((doalloc&1), xsiz, ysiz, intexfmt, texfmt, (coltype*)fptr, xsiz, ysiz, 0|8192);
free((void*)fptr);
}
@ -847,6 +849,7 @@ int mdloadskin(md2model *m, int number, int pal, int surf)
// save off the compressed version
cachead.xdim = osizx;
cachead.ydim = osizy;
cachead.quality = r_downsize;
i = 0;
for (j=0;j<31;j++)
{

View file

@ -182,6 +182,9 @@ int r_cullobstructedmodels = 0;
// fullbright cvar
int r_fullbrights = 1;
// texture downsizing
int r_downsize = 0;
static float fogresult, fogcol[4];
// making this a macro should speed things up at the expense of code size
@ -329,6 +332,7 @@ typedef struct
char magic[8]; // 'Polymost'
int xdim, ydim; // of image, unpadded
int flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed
int quality; // r_downsize at the time the cache was written
} texcacheheader;
typedef struct
{
@ -968,6 +972,9 @@ static void uploadtexture(int doalloc, int xsiz, int ysiz, int intexfmt, int tex
{
coltype *wpptr, *rpptr;
int x2, y2, j, js=0, x3, y3, y, x, r, g, b, a, k;
int hi = (dameth&8192);
dameth &= ~8192;
if (gltexmaxsize <= 0)
{
@ -985,6 +992,8 @@ static void uploadtexture(int doalloc, int xsiz, int ysiz, int intexfmt, int tex
gltexmiplevel = js;
while ((xsiz>>js) > (1<<gltexmaxsize) || (ysiz>>js) > (1<<gltexmaxsize)) js++;
if (hi) js = r_downsize;
/*
OSD_Printf("Uploading %dx%d %s as %s\n", xsiz,ysiz,
(texfmt==GL_RGBA?"GL_RGBA":
@ -1237,7 +1246,9 @@ int trytexcache(char *fn, int len, int dameth, char effect, texcacheheader *head
head->xdim = B_LITTLE32(head->xdim);
head->ydim = B_LITTLE32(head->ydim);
head->flags = B_LITTLE32(head->flags);
head->quality = B_LITTLE32(head->quality);
if (head->quality != r_downsize) goto failure;
if (gltexmaxsize && (head->xdim > (1<<gltexmaxsize) || head->ydim > (1<<gltexmaxsize))) goto failure;
if (!glinfo.texnpot && (head->flags & 1)) goto failure;
@ -1320,6 +1331,7 @@ void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *hea
head->xdim = B_LITTLE32(head->xdim);
head->ydim = B_LITTLE32(head->ydim);
head->flags = B_LITTLE32(head->flags);
head->quality = B_LITTLE32(head->quality);
if (Bwrite(fil, head, sizeof(texcacheheader)) != sizeof(texcacheheader)) goto failure;
@ -1644,7 +1656,7 @@ int gloadtile_hi(int dapic,int dapalnum, int facen, hicreplctyp *hicr, int damet
cachefil=0;
}
fixtransparency(pic,tsizx,tsizy,xsiz,ysiz,dameth);
uploadtexture(doalloc,xsiz,ysiz,intexfmt,texfmt,pic,-1,tsizy,dameth);
uploadtexture(doalloc,xsiz,ysiz,intexfmt,texfmt,pic,-1,tsizy,dameth|8192);
}
// precalculate scaling parameters for replacement
@ -1695,6 +1707,7 @@ int gloadtile_hi(int dapic,int dapalnum, int facen, hicreplctyp *hicr, int damet
// save off the compressed version
cachead.xdim = tsizx;
cachead.ydim = tsizy;
cachead.quality = r_downsize;
x = 0;
for (j=0;j<31;j++)
{
@ -5982,6 +5995,19 @@ static int osdcmd_polymostvars(const osdfuncparm_t *parm)
else setvsync(val != 0);
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->name, "r_downsize"))
{
if (showval) { OSD_Printf("r_downsize is %d\n", r_downsize); }
else if (val < 0 || val > 5) { OSD_Printf("Value out of range.\n"); }
else
{
r_downsize = val;
resetvideomode();
if (setgamemode(fullscreen,xdim,ydim,bpp))
OSD_Printf("restartvid: Reset failed...\n");
}
return OSDCMD_OK;
}
#endif
return OSDCMD_SHOWHELP;
}
@ -6024,6 +6050,7 @@ void polymost_initosdfuncs(void)
OSD_RegisterFunction("r_curpeel","r_curpeel: allows to display one depth layer at a time (for development purposes)",osdcmd_polymostvars);
OSD_RegisterFunction("r_depthpeeling","r_depthpeeling: enable/disable order-independant transparency",osdcmd_polymostvars);
OSD_RegisterFunction("r_detailmapping","r_detailmapping: enable/disable detail mapping",osdcmd_polymostvars);
OSD_RegisterFunction("r_downsize","r_downsize: controls downsizing factor for hires textures",osdcmd_polymostvars);
OSD_RegisterFunction("r_fullbrights","r_fullbrights: enable/disable fullbright textures",osdcmd_polymostvars);
OSD_RegisterFunction("r_glowmapping","r_glowmapping: enable/disable glow mapping",osdcmd_polymostvars);
OSD_RegisterFunction("r_multisample","r_multisample: sets the number of samples used for antialiasing (0 = off)",osdcmd_polymostvars);

View file

@ -706,6 +706,7 @@ int32 CONFIG_ReadSetup(void)
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping", &r_parallaxskyclamping);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning", &r_parallaxskypanning);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLCullObstructedModels", &r_cullobstructedmodels);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLTextureQuality", &r_downsize);
dummy = usemodels;
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "UseModels",&dummy);
usemodels = dummy != 0;
@ -926,6 +927,7 @@ void CONFIG_WriteSetup(void)
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping",r_parallaxskyclamping,false,false);
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning",r_parallaxskypanning,false,false);
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLCullObstructedModels", r_cullobstructedmodels,false,false);
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLTextureQuality", r_downsize,false,false);
#endif
#ifdef RENDERTYPEWIN
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq",maxrefreshfreq,false,false);

View file

@ -284,6 +284,7 @@ int gametext_z(int small, int starttile, int x,int y,const char *t,int s,int p,i
int ac,newx,oldx=x;
char centre, *oldt;
int squishtext = (small == 2);
int ht = usehightile;
small &= ~2;
@ -323,7 +324,7 @@ int gametext_z(int small, int starttile, int x,int y,const char *t,int s,int p,i
t = oldt;
x = (320>>1)-(newx>>1);
}
usehightile = (ht && !r_downsize);
while (*t)
{
if (*t == '^' && isdigit(*(t+1)))
@ -364,7 +365,7 @@ int gametext_z(int small, int starttile, int x,int y,const char *t,int s,int p,i
if (x > (ud.config.ScreenWidth - 14)) oldt = (char *)t, x = oldx, y+=8*z/65536;
t++;
}
usehightile = ht;
return (x);
}
@ -408,10 +409,12 @@ static int minitext_(int x,int y,const char *t,int s,int p,int sb)
{
int ac;
char ch,cmode;
int ht = usehightile;
cmode = (sb&256)!=0;
sb &= 255;
usehightile = (ht && !r_downsize);
while (*t)
{
ch = Btoupper(*t);
@ -429,6 +432,7 @@ static int minitext_(int x,int y,const char *t,int s,int p,int sb)
t++;
}
usehightile = ht;
return (x);
}

View file

@ -194,6 +194,7 @@ static inline int probesm(int x,int y,int i,int n)
int menutext(int x,int y,int s,int p,char *t)
{
short i, ac, centre;
int ht = usehightile;
t = (char *)stripcolorcodes(t);
y -= 12;
@ -257,6 +258,7 @@ int menutext(int x,int y,int s,int p,char *t)
if (centre)
x = (320-centre-10)>>1;
usehightile = (ht && r_downsize < 3);
while (*t)
{
if (*t == ' ')
@ -309,6 +311,7 @@ int menutext(int x,int y,int s,int p,char *t)
x += tilesizx[ac];
t++;
}
usehightile = ht;
return (x);
}
@ -327,54 +330,36 @@ static void _bar(int type, int x,int y,int *p,int dainc,int damodify,int s, int
if (damodify)
{
if (rev == 0)
{
if (*p > min && (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || ((buttonstat&1) && (WHEELUP || mii < -256)))) // && onbar) )
if (*p >= min && *p <= max && (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || ((buttonstat&1) && (WHEELUP || mii < -256)))) // && onbar) )
{
KB_ClearKeyDown(sc_LeftArrow);
KB_ClearKeyDown(sc_kpad_4);
MOUSE_ClearButton(WHEELUP_MOUSE);
mii = 0;
if (!rev)
*p -= dainc;
else *p += dainc;
if (*p < min)
*p = min;
if (*p > max)
*p = max;
sound(KICK_HIT);
}
if (*p < max && (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || ((buttonstat&1) && (WHEELDOWN || mii > 256)))) //&& onbar) )
if (*p <= max && *p >= min && (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || ((buttonstat&1) && (WHEELDOWN || mii > 256)))) //&& onbar) )
{
KB_ClearKeyDown(sc_RightArrow);
KB_ClearKeyDown(sc_kpad_6);
MOUSE_ClearButton(WHEELDOWN_MOUSE);
mii = 0;
if (!rev)
*p += dainc;
else *p -= dainc;
if (*p > max)
*p = max;
sound(KICK_HIT);
}
}
else
{
if (*p > min && (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || ((buttonstat&1) && minfo.dyaw > 256))) //&& onbar) )
{
KB_ClearKeyDown(sc_RightArrow);
KB_ClearKeyDown(sc_kpad_6);
*p -= dainc;
if (*p < min)
*p = min;
sound(KICK_HIT);
}
if (*p < max && (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || ((buttonstat&1) && minfo.dyaw < -256))) // && onbar) )
{
KB_ClearKeyDown(sc_LeftArrow);
KB_ClearKeyDown(sc_kpad_4);
*p += dainc;
if (*p > max)
*p = max;
sound(KICK_HIT);
}
}
}
xloc = *p;
@ -2182,7 +2167,7 @@ cheat_for_port_credits:
scale(320-40+4,xdim,320)-1,scale(12+32+112+4,ydim,200)-1);
// path
minitext(52,32,boardfilename,0,26);
minitext(38,45,boardfilename,0,26);
{
// JBF 20040208: seek to first name matching pressed character
@ -2238,33 +2223,33 @@ cheat_for_port_credits:
}
}
}
mgametext(40+4,12+32,"DIRECTORIES",0,2+8+16);
mgametext(40+4,32,"DIRECTORIES",0,2+8+16);
if (finddirshigh)
{
dir = finddirshigh;
for (i=0; i<2; i++) if (!dir->prev) break;
for (i=0; i<6; i++) if (!dir->prev) break;
else dir=dir->prev;
for (i=2; i>-2 && dir; i--, dir=dir->next)
for (i=6; i>-7 && dir; i--, dir=dir->next)
{
if (dir == finddirshigh) c=0;
else c=16;
minitextshade(40,1+12+32+8*(3-i),dir->name,c,0,26);
minitextshade(40,1+12+32+8*(7-i),dir->name,c,0,26);
}
}
mgametext(40+4,8+32+40+8-1,"MAP FILES",0,2+8+16);
mgametext(180+4,32,"MAP FILES",0,2+8+16);
if (findfileshigh)
{
dir = findfileshigh;
for (i=0; i<4; i++) if (!dir->prev) break;
for (i=0; i<7; i++) if (!dir->prev) break;
else dir=dir->prev;
for (i=4; i>-4 && dir; i--, dir=dir->next)
for (i=7; i>-7 && dir; i--, dir=dir->next)
{
if (dir == findfileshigh) c=0;
else c=16;
minitextshade(40,(8+32+8*5)+8*(6-i),dir->name,c,2,26);
minitextshade(180,1+12+32+8*(7-i),dir->name,c,2,26);
}
}
@ -2283,8 +2268,8 @@ cheat_for_port_credits:
onbar = 0;
probey = 2;
if (currentlist == 0) x = probe(50,12+32+16+4,0,3);
else x = probe(50,8+32+40+40+4,0,3);
if (currentlist == 0) x = probesm(45,32+4+1,0,3);
else x = probesm(185,32+4+1,0,3);
if (probey == 1)
{
@ -2423,11 +2408,13 @@ cheat_for_port_credits:
int io, ii, yy, d=c+160+40, enabled;
char *opts[] =
{
"Use widescreen hack",
"-",
"Widescreen",
"Anisotropic filtering",
"Use VSync",
"Ambient light level",
"-",
"Enable hires textures",
"Hires texture quality",
"Precache hires textures",
"GL texture compression",
"Cache textures on disk",
@ -2437,9 +2424,7 @@ cheat_for_port_credits:
"-",
"Use models",
"Blend model animations",
"-",
"Ambient light level",
"Use VSync",
"Cull obstructed models",
NULL
};
@ -2455,7 +2440,7 @@ cheat_for_port_credits:
io++;
}
onbar = (probey==11);
onbar = (probey==3||probey==5);
x = probesm(c,yy+5,0,io);
if (x == -1)
@ -2498,70 +2483,6 @@ cheat_for_port_credits:
break;
}
case 2:
if (x==io) usehightile = 1-usehightile;
modval(0,1,(int *)&usehightile,1,probey==io);
mgametextpal(d,yy, usehightile ? "Yes" : "No", MENUHIGHLIGHT(io), 0);
break;
case 3:
enabled = usehightile;
if (enabled && x==io) ud.config.useprecache = !ud.config.useprecache;
if (enabled) modval(0,1,(int *)&ud.config.useprecache,1,probey==io);
mgametextpal(d,yy, ud.config.useprecache && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 4:
enabled = usehightile;
if (enabled && x==io) glusetexcompr = !glusetexcompr;
if (enabled) modval(0,1,(int *)&glusetexcompr,1,probey==io);
mgametextpal(d,yy, glusetexcompr && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 5:
enabled = (glusetexcompr && usehightile);
if (enabled && x==io) glusetexcache = !glusetexcache;
if (enabled) modval(0,1,(int *)&glusetexcache,1,probey==io);
mgametextpal(d,yy, glusetexcache && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 6:
enabled = (glusetexcompr && usehightile && glusetexcache);
if (enabled && x==io) glusetexcachecompression = !glusetexcachecompression;
if (enabled) modval(0,1,(int *)&glusetexcachecompression,1,probey==io);
mgametextpal(d,yy, glusetexcachecompression && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 7:
enabled = usehightile;
if (enabled && x==io) r_detailmapping = !r_detailmapping;
if (enabled) modval(0,1,(int *)&r_detailmapping,1,probey==io);
mgametextpal(d,yy, r_detailmapping && enabled ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 8:
enabled = usehightile;
if (enabled && x==io) r_glowmapping = !r_glowmapping;
if (enabled) modval(0,1,(int *)&r_glowmapping,1,probey==io);
mgametextpal(d,yy, r_glowmapping && enabled ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 9:
if (x==io) usemodels = 1-usemodels;
modval(0,1,(int *)&usemodels,1,probey==io);
mgametextpal(d,yy, usemodels ? "Yes" : "No", MENUHIGHLIGHT(io), 0);
break;
case 10:
enabled = usemodels;
if (enabled && x==io) r_animsmoothing = !r_animsmoothing;
if (enabled) modval(0,1,(int *)&r_animsmoothing,1,probey==io);
mgametextpal(d,yy, r_animsmoothing && enabled ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 11:
{
int i = (float)r_ambientlight*1024.f;
int j = i;
_bar(1,d+8,yy+7, &i,128,x==io,MENUHIGHLIGHT(io),numplayers>1,128,4096);
if (i != j)
{
r_ambientlight = (float)i/1024.f;
r_ambientlightrecip = 1.f/r_ambientlight;
}
break;
}
case 12:
{
int ovsync = vsync;
if (x==io) vsync = !vsync;
@ -2571,6 +2492,89 @@ cheat_for_port_credits:
setvsync(vsync);
break;
}
case 3:
{
int i = (float)r_ambientlight*1024.f;
int j = i;
_bar(1,d+8,yy+7, &i,128,x==io,MENUHIGHLIGHT(io),0,128,4096);
if (i != j)
{
r_ambientlight = (float)i/1024.f;
r_ambientlightrecip = 1.f/r_ambientlight;
}
break;
}
case 4:
if (x==io) usehightile = 1-usehightile;
modval(0,1,(int *)&usehightile,1,probey==io);
mgametextpal(d,yy, usehightile ? "Yes" : "No", MENUHIGHLIGHT(io), 0);
break;
case 5:
{
i = r_downsize;
enabled = usehightile;
_bar(1,d+8,yy+7, &r_downsize,-1,enabled && x==io,MENUHIGHLIGHT(io),!enabled,0,5);
if (r_downsize != i)
{
resetvideomode();
if (setgamemode(fullscreen,xdim,ydim,bpp))
OSD_Printf("restartvid: Reset failed...\n");
}
break;
}
case 6:
enabled = usehightile;
if (enabled && x==io) ud.config.useprecache = !ud.config.useprecache;
if (enabled) modval(0,1,(int *)&ud.config.useprecache,1,probey==io);
mgametextpal(d,yy, ud.config.useprecache && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 7:
enabled = usehightile;
if (enabled && x==io) glusetexcompr = !glusetexcompr;
if (enabled) modval(0,1,(int *)&glusetexcompr,1,probey==io);
mgametextpal(d,yy, glusetexcompr && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 8:
enabled = (glusetexcompr && usehightile);
if (enabled && x==io) glusetexcache = !glusetexcache;
if (enabled) modval(0,1,(int *)&glusetexcache,1,probey==io);
mgametextpal(d,yy, glusetexcache && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 9:
enabled = (glusetexcompr && usehightile && glusetexcache);
if (enabled && x==io) glusetexcachecompression = !glusetexcachecompression;
if (enabled) modval(0,1,(int *)&glusetexcachecompression,1,probey==io);
mgametextpal(d,yy, glusetexcachecompression && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 10:
enabled = usehightile;
if (enabled && x==io) r_detailmapping = !r_detailmapping;
if (enabled) modval(0,1,(int *)&r_detailmapping,1,probey==io);
mgametextpal(d,yy, r_detailmapping && enabled ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 11:
enabled = usehightile;
if (enabled && x==io) r_glowmapping = !r_glowmapping;
if (enabled) modval(0,1,(int *)&r_glowmapping,1,probey==io);
mgametextpal(d,yy, r_glowmapping && enabled ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 12:
if (x==io) usemodels = 1-usemodels;
modval(0,1,(int *)&usemodels,1,probey==io);
mgametextpal(d,yy, usemodels ? "Yes" : "No", MENUHIGHLIGHT(io), 0);
break;
case 13:
enabled = usemodels;
if (enabled && x==io) r_animsmoothing = !r_animsmoothing;
if (enabled) modval(0,1,(int *)&r_animsmoothing,1,probey==io);
mgametextpal(d,yy, r_animsmoothing && enabled ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
case 14:
enabled = usemodels;
if (enabled && x==io) r_cullobstructedmodels = !r_cullobstructedmodels;
if (enabled) modval(0,1,(int *)&r_cullobstructedmodels,1,probey==io);
mgametextpal(d,yy, r_cullobstructedmodels && enabled ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break;
default:
break;
}