Small cleanup
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@584 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
42dd108d9d
commit
f879422fb7
1 changed files with 57 additions and 158 deletions
|
@ -2322,6 +2322,49 @@ qboolean GL_UploadCompressed (qbyte *file, int *out_width, int *out_height, unsi
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GL_RoundDimensions(int *scaled_width, int *scaled_height, qboolean mipmap)
|
||||||
|
{
|
||||||
|
if (gl_config.arb_texture_non_power_of_two) //NPOT is a simple extension that relaxes errors.
|
||||||
|
{
|
||||||
|
TRACE(("dbg: GL_RoundDimensions: GL_ARB_texture_non_power_of_two\n"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int width = *scaled_width;
|
||||||
|
int height = *scaled_height;
|
||||||
|
for (*scaled_width = 1 ; *scaled_width < width ; *scaled_width<<=1)
|
||||||
|
;
|
||||||
|
for (*scaled_height = 1 ; *scaled_height < height ; *scaled_height<<=1)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mipmap)
|
||||||
|
{
|
||||||
|
TRACE(("dbg: GL_RoundDimensions: %f\n", gl_picmip.value));
|
||||||
|
*scaled_width >>= (int)gl_picmip.value;
|
||||||
|
*scaled_height >>= (int)gl_picmip.value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*scaled_width >>= (int)gl_picmip2d.value;
|
||||||
|
*scaled_height >>= (int)gl_picmip2d.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE(("dbg: GL_RoundDimensions: %f\n", gl_max_size.value));
|
||||||
|
if (gl_max_size.value)
|
||||||
|
{
|
||||||
|
if (*scaled_width > gl_max_size.value)
|
||||||
|
*scaled_width = gl_max_size.value;
|
||||||
|
if (*scaled_height > gl_max_size.value)
|
||||||
|
*scaled_height = gl_max_size.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*scaled_width < 1)
|
||||||
|
*scaled_width = 1;
|
||||||
|
if (*scaled_height < 1)
|
||||||
|
*scaled_height = 1;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
GL_Upload32
|
GL_Upload32
|
||||||
|
@ -2336,45 +2379,9 @@ void GL_Upload32 (char *name, unsigned *data, int width, int height, qboolean m
|
||||||
|
|
||||||
TRACE(("dbg: GL_Upload32: %s %i %i\n", name, width, height));
|
TRACE(("dbg: GL_Upload32: %s %i %i\n", name, width, height));
|
||||||
|
|
||||||
if (gl_config.arb_texture_non_power_of_two) //NPOT is a simple extension that relaxes errors.
|
scaled_width = width;
|
||||||
{
|
scaled_height = height;
|
||||||
TRACE(("dbg: GL_Upload32: GL_ARB_texture_non_power_of_two\n"));
|
GL_RoundDimensions(&scaled_width, &scaled_height, mipmap);
|
||||||
scaled_width = width;
|
|
||||||
scaled_height = height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)
|
|
||||||
;
|
|
||||||
for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mipmap)
|
|
||||||
{
|
|
||||||
TRACE(("dbg: GL_Upload32: %f\n", gl_picmip.value));
|
|
||||||
scaled_width >>= (int)gl_picmip.value;
|
|
||||||
scaled_height >>= (int)gl_picmip.value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scaled_width >>= (int)gl_picmip2d.value;
|
|
||||||
scaled_height >>= (int)gl_picmip2d.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE(("dbg: GL_Upload32: %f\n", gl_max_size.value));
|
|
||||||
if (gl_max_size.value)
|
|
||||||
{
|
|
||||||
if (scaled_width > gl_max_size.value)
|
|
||||||
scaled_width = gl_max_size.value;
|
|
||||||
if (scaled_height > gl_max_size.value)
|
|
||||||
scaled_height = gl_max_size.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scaled_width < 1)
|
|
||||||
scaled_width = 1;
|
|
||||||
if (scaled_height < 1)
|
|
||||||
scaled_height = 1;
|
|
||||||
|
|
||||||
TRACE(("dbg: GL_Upload32: %i %i\n", scaled_width, scaled_height));
|
TRACE(("dbg: GL_Upload32: %i %i\n", scaled_width, scaled_height));
|
||||||
|
|
||||||
|
@ -2513,44 +2520,9 @@ void GL_Upload8Grey (unsigned char*data, int width, int height, qboolean mipmap
|
||||||
unsigned char *scaled = uploadmemorybuffer;
|
unsigned char *scaled = uploadmemorybuffer;
|
||||||
int scaled_width, scaled_height;
|
int scaled_width, scaled_height;
|
||||||
|
|
||||||
if (gl_config.arb_texture_non_power_of_two) //NPOT is a simple extension that relaxes errors.
|
scaled_width = width;
|
||||||
{
|
scaled_height = height;
|
||||||
TRACE(("dbg: GL_Upload32: GL_ARB_texture_non_power_of_two\n"));
|
GL_RoundDimensions(&scaled_width, &scaled_height, mipmap);
|
||||||
scaled_width = width;
|
|
||||||
scaled_height = height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)
|
|
||||||
;
|
|
||||||
for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mipmap)
|
|
||||||
{
|
|
||||||
TRACE(("dbg: GL_Upload8Grey: %f\n", gl_picmip.value));
|
|
||||||
scaled_width >>= (int)gl_picmip.value;
|
|
||||||
scaled_height >>= (int)gl_picmip.value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scaled_width >>= (int)gl_picmip2d.value;
|
|
||||||
scaled_height >>= (int)gl_picmip2d.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gl_max_size.value)
|
|
||||||
{
|
|
||||||
if (scaled_width > gl_max_size.value)
|
|
||||||
scaled_width = gl_max_size.value;
|
|
||||||
if (scaled_height > gl_max_size.value)
|
|
||||||
scaled_height = gl_max_size.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scaled_width < 1)
|
|
||||||
scaled_width = 1;
|
|
||||||
if (scaled_height < 1)
|
|
||||||
scaled_height = 1;
|
|
||||||
|
|
||||||
if (scaled_width * scaled_height > sizeofuploadmemorybuffer/4)
|
if (scaled_width * scaled_height > sizeofuploadmemorybuffer/4)
|
||||||
Sys_Error ("GL_LoadTexture: too big");
|
Sys_Error ("GL_LoadTexture: too big");
|
||||||
|
@ -2726,56 +2698,17 @@ unsigned int * genNormalMap(qbyte *pixels, int w, int h, float scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
//PENTA
|
//PENTA
|
||||||
void GL_UploadBump(qbyte *data, int width, int height, qboolean mipmap) {
|
void GL_UploadBump(qbyte *data, int width, int height, qboolean mipmap)
|
||||||
|
{
|
||||||
int s;
|
|
||||||
unsigned char *scaled = uploadmemorybuffer;
|
unsigned char *scaled = uploadmemorybuffer;
|
||||||
int scaled_width, scaled_height;
|
int scaled_width, scaled_height;
|
||||||
qbyte *nmap;
|
qbyte *nmap;
|
||||||
|
|
||||||
TRACE(("dbg: GL_UploadBump entered: %i %i\n", width, height));
|
TRACE(("dbg: GL_UploadBump entered: %i %i\n", width, height));
|
||||||
|
|
||||||
s = width*height;
|
scaled_width = width;
|
||||||
|
scaled_height = height;
|
||||||
//Resize to power of 2 and maximum texture size
|
GL_RoundDimensions(&scaled_width, &scaled_height, mipmap);
|
||||||
if (gl_config.arb_texture_non_power_of_two) //NPOT is a simple extension that relaxes errors.
|
|
||||||
{
|
|
||||||
TRACE(("dbg: GL_Upload32: GL_ARB_texture_non_power_of_two\n"));
|
|
||||||
scaled_width = width;
|
|
||||||
scaled_height = height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)
|
|
||||||
;
|
|
||||||
for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mipmap)
|
|
||||||
{
|
|
||||||
TRACE(("dbg: GL_UploadBump: %f\n", gl_picmip.value));
|
|
||||||
scaled_width >>= (int)gl_picmip.value;
|
|
||||||
scaled_height >>= (int)gl_picmip.value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scaled_width >>= (int)gl_picmip2d.value;
|
|
||||||
scaled_height >>= (int)gl_picmip2d.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gl_max_size.value)
|
|
||||||
{
|
|
||||||
if (scaled_width > gl_max_size.value)
|
|
||||||
scaled_width = gl_max_size.value;
|
|
||||||
if (scaled_height > gl_max_size.value)
|
|
||||||
scaled_height = gl_max_size.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scaled_width < 1)
|
|
||||||
scaled_width = 1;
|
|
||||||
if (scaled_height < 1)
|
|
||||||
scaled_height = 1;
|
|
||||||
|
|
||||||
if (scaled_width * scaled_height > sizeofuploadmemorybuffer/4)
|
if (scaled_width * scaled_height > sizeofuploadmemorybuffer/4)
|
||||||
Sys_Error ("GL_LoadTexture: too big");
|
Sys_Error ("GL_LoadTexture: too big");
|
||||||
|
@ -2874,44 +2807,10 @@ void GL_Upload8_EXT (qbyte *data, int width, int height, qboolean mipmap, qbool
|
||||||
if (alpha && noalpha)
|
if (alpha && noalpha)
|
||||||
alpha = false;
|
alpha = false;
|
||||||
}
|
}
|
||||||
if (supported_GL_ARB_texture_non_power_of_two) //NPOT is a simple extension that relaxes errors.
|
|
||||||
{
|
|
||||||
TRACE(("dbg: GL_Upload32: GL_ARB_texture_non_power_of_two\n"));
|
|
||||||
scaled_width = width;
|
|
||||||
scaled_height = height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)
|
|
||||||
;
|
|
||||||
for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mipmap)
|
scaled_width = width;
|
||||||
{
|
scaled_height = height;
|
||||||
TRACE(("dbg: GL_Upload8_EXT: %f\n", gl_picmip.value));
|
GL_RoundDimensions(&scaled_width, &scaled_height, mipmap);
|
||||||
scaled_width >>= (int)gl_picmip.value;
|
|
||||||
scaled_height >>= (int)gl_picmip.value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scaled_width >>= (int)gl_picmip2d.value;
|
|
||||||
scaled_height >>= (int)gl_picmip2d.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gl_max_size.value)
|
|
||||||
{
|
|
||||||
if (scaled_width > gl_max_size.value)
|
|
||||||
scaled_width = gl_max_size.value;
|
|
||||||
if (scaled_height > gl_max_size.value)
|
|
||||||
scaled_height = gl_max_size.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scaled_width < 1)
|
|
||||||
scaled_width = 1;
|
|
||||||
if (scaled_height < 1)
|
|
||||||
scaled_height = 1;
|
|
||||||
|
|
||||||
if (scaled_width * scaled_height > sizeofuploadmemorybufferintermediate/4)
|
if (scaled_width * scaled_height > sizeofuploadmemorybufferintermediate/4)
|
||||||
Sys_Error ("GL_LoadTexture: too big");
|
Sys_Error ("GL_LoadTexture: too big");
|
||||||
|
|
Loading…
Reference in a new issue