summaryrefslogtreecommitdiff
path: root/src/gl_images.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gl_images.c')
-rw-r--r--src/gl_images.c706
1 files changed, 369 insertions, 337 deletions
diff --git a/src/gl_images.c b/src/gl_images.c
index 1c2b49f..d36b605 100644
--- a/src/gl_images.c
+++ b/src/gl_images.c
@@ -9,7 +9,7 @@ of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
@@ -49,7 +49,7 @@ static cvar_t *gl_intensity;
static cvar_t *gl_gamma;
static cvar_t *gl_invert;
-static qboolean GL_Upload8( byte *data, int width, int height, qboolean mipmap );
+static qboolean GL_Upload8(byte *data, int width, int height, qboolean mipmap);
typedef struct {
const char *name;
@@ -65,7 +65,7 @@ static const glmode_t filterModes[] = {
{ "GL_LINEAR_MIPMAP_LINEAR", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR }
};
-static const int numFilterModes = sizeof( filterModes ) / sizeof( filterModes[0] );
+static const int numFilterModes = sizeof(filterModes) / sizeof(filterModes[0]);
typedef struct {
const char *name;
@@ -81,7 +81,7 @@ static const gltmode_t alphaModes[] = {
{ "GL_RGBA2", GL_RGBA2 }
};
-static const int numAlphaModes = sizeof( alphaModes ) / sizeof( alphaModes[0] );
+static const int numAlphaModes = sizeof(alphaModes) / sizeof(alphaModes[0]);
static const gltmode_t solidModes[] = {
{ "default", 4 },
@@ -96,20 +96,21 @@ static const gltmode_t solidModes[] = {
#endif
};
-static const int numSolidModes = sizeof( solidModes ) / sizeof( solidModes[0] );
+static const int numSolidModes = sizeof(solidModes) / sizeof(solidModes[0]);
-static void gl_texturemode_changed( cvar_t *self ) {
+static void gl_texturemode_changed(cvar_t *self)
+{
int i;
image_t *image;
- for( i = 0; i < numFilterModes ; i++ ) {
- if( !Q_stricmp( filterModes[i].name, self->string ) )
+ for (i = 0; i < numFilterModes; i++) {
+ if (!Q_stricmp(filterModes[i].name, self->string))
break;
}
- if( i == numFilterModes ) {
- Com_WPrintf( "Bad texture mode: %s\n", self->string );
- Cvar_Reset( self );
+ if (i == numFilterModes) {
+ Com_WPrintf("Bad texture mode: %s\n", self->string);
+ Cvar_Reset(self);
gl_filter_min = GL_LINEAR_MIPMAP_LINEAR;
gl_filter_max = GL_LINEAR;
} else {
@@ -118,83 +119,87 @@ static void gl_texturemode_changed( cvar_t *self ) {
}
// change all the existing mipmap texture objects
- for( i = 0, image = r_images; i < r_numImages; i++, image++ ) {
- if( image->type == it_wall || image->type == it_skin ) {
- GL_BindTexture( image->texnum );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
- gl_filter_min );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
- gl_filter_max );
+ for (i = 0, image = r_images; i < r_numImages; i++, image++) {
+ if (image->type == it_wall || image->type == it_skin) {
+ GL_BindTexture(image->texnum);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ gl_filter_min);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+ gl_filter_max);
}
}
}
-static void gl_texturemode_g( genctx_t *ctx ) {
+static void gl_texturemode_g(genctx_t *ctx)
+{
int i;
-
- for( i = 0; i < numFilterModes ; i++ ) {
- if( !Prompt_AddMatch( ctx, filterModes[i].name ) ) {
+
+ for (i = 0; i < numFilterModes; i++) {
+ if (!Prompt_AddMatch(ctx, filterModes[i].name)) {
break;
}
}
}
-static void gl_anisotropy_changed( cvar_t *self ) {
+static void gl_anisotropy_changed(cvar_t *self)
+{
int i;
image_t *image;
- if( gl_config.maxAnisotropy < 2 ) {
+ if (gl_config.maxAnisotropy < 2) {
return;
}
gl_filter_anisotropy = self->value;
- clamp( gl_filter_anisotropy, 1, gl_config.maxAnisotropy );
+ clamp(gl_filter_anisotropy, 1, gl_config.maxAnisotropy);
// change all the existing mipmap texture objects
- for( i = 0, image = r_images; i < r_numImages; i++, image++ ) {
- if( image->type == it_wall || image->type == it_skin ) {
- GL_BindTexture( image->texnum );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,
- gl_filter_anisotropy );
+ for (i = 0, image = r_images; i < r_numImages; i++, image++) {
+ if (image->type == it_wall || image->type == it_skin) {
+ GL_BindTexture(image->texnum);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,
+ gl_filter_anisotropy);
}
}
}
-static void gl_bilerp_chars_changed( cvar_t *self ) {
+static void gl_bilerp_chars_changed(cvar_t *self)
+{
int i;
image_t *image;
GLfloat param = self->integer ? GL_LINEAR : GL_NEAREST;
// change all the existing charset texture objects
- for( i = 0, image = r_images; i < r_numImages; i++, image++ ) {
- if( image->type == it_charset ) {
- GL_BindTexture( image->texnum );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, param );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, param );
+ for (i = 0, image = r_images; i < r_numImages; i++, image++) {
+ if (image->type == it_charset) {
+ GL_BindTexture(image->texnum);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, param);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, param);
}
}
}
-static void gl_bilerp_pics_changed( cvar_t *self ) {
+static void gl_bilerp_pics_changed(cvar_t *self)
+{
int i;
image_t *image;
GLfloat param = self->integer ? GL_LINEAR : GL_NEAREST;
// change all the existing pic texture objects
- for( i = 0, image = r_images; i < r_numImages; i++, image++ ) {
- if( image->type == it_pic ) {
- GL_BindTexture( image->texnum );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, param );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, param );
+ for (i = 0, image = r_images; i < r_numImages; i++, image++) {
+ if (image->type == it_pic) {
+ GL_BindTexture(image->texnum);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, param);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, param);
}
}
// change scrap texture object
- if( !gl_noscrap->integer ) {
+ if (!gl_noscrap->integer) {
param = self->integer > 1 ? GL_LINEAR : GL_NEAREST;
- GL_BindTexture( TEXNUM_SCRAP );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, param );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, param );
+ GL_BindTexture(TEXNUM_SCRAP);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, param);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, param);
}
}
@@ -204,26 +209,28 @@ static void gl_bilerp_pics_changed( cvar_t *self ) {
GL_TextureAlphaMode
===============
*/
-static void GL_TextureAlphaMode( void ) {
+static void GL_TextureAlphaMode(void)
+{
int i;
- for( i = 0; i < numAlphaModes; i++ ) {
- if( !Q_stricmp( alphaModes[i].name, gl_texturealphamode->string ) ) {
+ for (i = 0; i < numAlphaModes; i++) {
+ if (!Q_stricmp(alphaModes[i].name, gl_texturealphamode->string)) {
gl_tex_alpha_format = alphaModes[i].mode;
return;
}
}
- Com_WPrintf( "Bad texture alpha mode: %s\n", gl_texturealphamode->string );
- Cvar_Reset( gl_texturealphamode );
+ Com_WPrintf("Bad texture alpha mode: %s\n", gl_texturealphamode->string);
+ Cvar_Reset(gl_texturealphamode);
gl_tex_alpha_format = alphaModes[0].mode;
}
-static void gl_texturealphamode_g( genctx_t *ctx ) {
+static void gl_texturealphamode_g(genctx_t *ctx)
+{
int i;
-
- for( i = 0; i < numAlphaModes; i++ ) {
- if( !Prompt_AddMatch( ctx, alphaModes[i].name ) ) {
+
+ for (i = 0; i < numAlphaModes; i++) {
+ if (!Prompt_AddMatch(ctx, alphaModes[i].name)) {
break;
}
}
@@ -234,26 +241,28 @@ static void gl_texturealphamode_g( genctx_t *ctx ) {
GL_TextureSolidMode
===============
*/
-static void GL_TextureSolidMode( void ) {
+static void GL_TextureSolidMode(void)
+{
int i;
- for( i = 0; i < numSolidModes; i++ ) {
- if( !Q_stricmp( solidModes[i].name, gl_texturesolidmode->string ) ) {
+ for (i = 0; i < numSolidModes; i++) {
+ if (!Q_stricmp(solidModes[i].name, gl_texturesolidmode->string)) {
gl_tex_solid_format = solidModes[i].mode;
return;
}
}
- Com_WPrintf( "Bad texture solid mode: %s\n", gl_texturesolidmode->string );
- Cvar_Reset( gl_texturesolidmode );
+ Com_WPrintf("Bad texture solid mode: %s\n", gl_texturesolidmode->string);
+ Cvar_Reset(gl_texturesolidmode);
gl_tex_solid_format = solidModes[0].mode;
}
-static void gl_texturesolidmode_g( genctx_t *ctx ) {
+static void gl_texturesolidmode_g(genctx_t *ctx)
+{
int i;
-
- for( i = 0; i < numSolidModes; i++ ) {
- if( !Prompt_AddMatch( ctx, solidModes[i].name ) ) {
+
+ for (i = 0; i < numSolidModes; i++) {
+ if (!Prompt_AddMatch(ctx, solidModes[i].name)) {
break;
}
}
@@ -277,29 +286,32 @@ static int scrap_inuse[SCRAP_BLOCK_WIDTH];
static byte scrap_data[SCRAP_BLOCK_WIDTH * SCRAP_BLOCK_HEIGHT];
static qboolean scrap_dirty;
-#define Scrap_AllocBlock( w, h, s, t ) \
- GL_AllocBlock( SCRAP_BLOCK_WIDTH, SCRAP_BLOCK_HEIGHT, scrap_inuse, w, h, s, t )
+#define Scrap_AllocBlock(w, h, s, t) \
+ GL_AllocBlock(SCRAP_BLOCK_WIDTH, SCRAP_BLOCK_HEIGHT, scrap_inuse, w, h, s, t)
-static void Scrap_Init( void ) {
+static void Scrap_Init(void)
+{
// make scrap texture initially transparent
- memset( scrap_data, 255, sizeof( scrap_data ) );
+ memset(scrap_data, 255, sizeof(scrap_data));
}
-static void Scrap_Shutdown( void ) {
+static void Scrap_Shutdown(void)
+{
int i;
- for( i = 0; i < SCRAP_BLOCK_WIDTH; i++ ) {
+ for (i = 0; i < SCRAP_BLOCK_WIDTH; i++) {
scrap_inuse[i] = 0;
}
scrap_dirty = qfalse;
}
-void Scrap_Upload( void ) {
- if( !scrap_dirty ) {
+void Scrap_Upload(void)
+{
+ if (!scrap_dirty) {
return;
}
- GL_BindTexture( TEXNUM_SCRAP );
- GL_Upload8( scrap_data, SCRAP_BLOCK_WIDTH, SCRAP_BLOCK_HEIGHT, qfalse );
+ GL_BindTexture(TEXNUM_SCRAP);
+ GL_Upload8(scrap_data, SCRAP_BLOCK_WIDTH, SCRAP_BLOCK_HEIGHT, qfalse);
scrap_dirty = qfalse;
}
@@ -317,9 +329,9 @@ typedef struct {
// must be a power of 2
#define FLOODFILL_FIFO_SIZE 0x1000
-#define FLOODFILL_FIFO_MASK ( FLOODFILL_FIFO_SIZE - 1 )
+#define FLOODFILL_FIFO_MASK (FLOODFILL_FIFO_SIZE - 1)
-#define FLOODFILL_STEP( off, dx, dy ) \
+#define FLOODFILL_STEP(off, dx, dy) \
do { \
if (pos[off] == fillcolor) { \
pos[off] = 255; \
@@ -329,7 +341,7 @@ typedef struct {
} else if (pos[off] != 255) { \
fdc = pos[off]; \
} \
- } while( 0 )
+ } while(0)
/*
=================
@@ -338,15 +350,15 @@ Mod_FloodFillSkin
Fill background pixels so mipmapping doesn't have haloes
=================
*/
-static void R_FloodFillSkin( byte *skin, int skinwidth, int skinheight ) {
+static void R_FloodFillSkin(byte *skin, int skinwidth, int skinheight)
+{
byte fillcolor = *skin; // assume this is the pixel to fill
floodfill_t fifo[FLOODFILL_FIFO_SIZE];
int inpt = 0, outpt = 0;
int filledcolor = -1;
int i;
- if (filledcolor == -1)
- {
+ if (filledcolor == -1) {
filledcolor = 0;
// attempt to find opaque black
for (i = 0; i < 256; ++i)
@@ -373,11 +385,11 @@ static void R_FloodFillSkin( byte *skin, int skinwidth, int skinheight ) {
outpt = (outpt + 1) & FLOODFILL_FIFO_MASK;
- if (x > 0) FLOODFILL_STEP( -1, -1, 0 );
- if (x < skinwidth - 1) FLOODFILL_STEP( 1, 1, 0 );
- if (y > 0) FLOODFILL_STEP( -skinwidth, 0, -1 );
- if (y < skinheight - 1) FLOODFILL_STEP( skinwidth, 0, 1 );
-
+ if (x > 0) FLOODFILL_STEP(-1, -1, 0);
+ if (x < skinwidth - 1) FLOODFILL_STEP(1, 1, 0);
+ if (y > 0) FLOODFILL_STEP(-skinwidth, 0, -1);
+ if (y < skinheight - 1) FLOODFILL_STEP(skinwidth, 0, 1);
+
skin[x + skinwidth * y] = fdc;
}
}
@@ -397,7 +409,8 @@ Transform to grayscale by replacing color components with
overall pixel luminance computed from weighted color sum
================
*/
-static void GL_GrayScaleTexture( byte *in, int inwidth, int inheight ) {
+static void GL_GrayScaleTexture(byte *in, int inwidth, int inheight)
+{
int i, c;
byte *p;
float r, g, b, y;
@@ -405,14 +418,14 @@ static void GL_GrayScaleTexture( byte *in, int inwidth, int inheight ) {
p = in;
c = inwidth * inheight;
- for( i = 0; i < c; i++, p += 4 ) {
+ for (i = 0; i < c; i++, p += 4) {
r = p[0];
g = p[1];
b = p[2];
- y = LUMINANCE( r, g, b );
- p[0] = y + ( r - y ) * colorscale;
- p[1] = y + ( g - y ) * colorscale;
- p[2] = y + ( b - y ) * colorscale;
+ y = LUMINANCE(r, g, b);
+ p[0] = y + (r - y) * colorscale;
+ p[1] = y + (g - y) * colorscale;
+ p[2] = y + (b - y) * colorscale;
}
}
@@ -424,21 +437,22 @@ Scale up the pixel values in a texture to increase the
lighting range
================
*/
-static void GL_LightScaleTexture( byte *in, int inwidth, int inheight, qboolean mipmap ) {
+static void GL_LightScaleTexture(byte *in, int inwidth, int inheight, qboolean mipmap)
+{
int i, c;
byte *p;
p = in;
c = inwidth * inheight;
- if( mipmap ) {
- for( i = 0; i < c; i++, p += 4 ) {
+ if (mipmap) {
+ for (i = 0; i < c; i++, p += 4) {
p[0] = gammaintensitytable[p[0]];
p[1] = gammaintensitytable[p[1]];
p[2] = gammaintensitytable[p[2]];
}
} else {
- for( i = 0; i < c; i++, p += 4 ) {
+ for (i = 0; i < c; i++, p += 4) {
p[0] = gammatable[p[0]];
p[1] = gammatable[p[1]];
p[2] = gammatable[p[2]];
@@ -446,17 +460,18 @@ static void GL_LightScaleTexture( byte *in, int inwidth, int inheight, qboolean
}
}
-static void GL_ColorInvertTexture( byte *in, int inwidth, int inheight ) {
+static void GL_ColorInvertTexture(byte *in, int inwidth, int inheight)
+{
int i, c;
byte *p;
p = in;
c = inwidth * inheight;
- for( i = 0; i < c; i++, p += 4 ) {
- p[0] = 255-p[0];
- p[1] = 255-p[1];
- p[2] = 255-p[2];
+ for (i = 0; i < c; i++, p += 4) {
+ p[0] = 255 - p[0];
+ p[1] = 255 - p[1];
+ p[2] = 255 - p[2];
}
}
@@ -465,7 +480,8 @@ static void GL_ColorInvertTexture( byte *in, int inwidth, int inheight ) {
GL_ResampleTexture
================
*/
-static void GL_ResampleTexture( const byte *in, int inwidth, int inheight, byte *out, int outwidth, int outheight ) {
+static void GL_ResampleTexture(const byte *in, int inwidth, int inheight, byte *out, int outwidth, int outheight)
+{
int i, j;
const byte *inrow1, *inrow2;
unsigned frac, fracstep;
@@ -473,37 +489,37 @@ static void GL_ResampleTexture( const byte *in, int inwidth, int inheight, byte
const byte *pix1, *pix2, *pix3, *pix4;
float heightScale;
- if( outwidth > MAX_TEXTURE_SIZE ) {
- Com_Error( ERR_FATAL, "%s: outwidth > %d", __func__, MAX_TEXTURE_SIZE );
+ if (outwidth > MAX_TEXTURE_SIZE) {
+ Com_Error(ERR_FATAL, "%s: outwidth > %d", __func__, MAX_TEXTURE_SIZE);
}
fracstep = inwidth * 0x10000 / outwidth;
frac = fracstep >> 2;
- for( i = 0; i < outwidth; i++ ) {
- p1[i] = 4 * ( frac >> 16 );
+ for (i = 0; i < outwidth; i++) {
+ p1[i] = 4 * (frac >> 16);
frac += fracstep;
}
- frac = 3 * ( fracstep >> 2 );
- for( i = 0; i < outwidth; i++ ) {
- p2[i] = 4 * ( frac >> 16 );
+ frac = 3 * (fracstep >> 2);
+ for (i = 0; i < outwidth; i++) {
+ p2[i] = 4 * (frac >> 16);
frac += fracstep;
}
- heightScale = ( float )inheight / outheight;
+ heightScale = (float)inheight / outheight;
inwidth <<= 2;
- for( i = 0; i < outheight; i++ ) {
- inrow1 = in + inwidth * ( int )( ( i + 0.25f ) * heightScale );
- inrow2 = in + inwidth * ( int )( ( i + 0.75f ) * heightScale );
- for( j = 0; j < outwidth; j++ ) {
+ for (i = 0; i < outheight; i++) {
+ inrow1 = in + inwidth * (int)((i + 0.25f) * heightScale);
+ inrow2 = in + inwidth * (int)((i + 0.75f) * heightScale);
+ for (j = 0; j < outwidth; j++) {
pix1 = inrow1 + p1[j];
pix2 = inrow1 + p2[j];
pix3 = inrow2 + p1[j];
pix4 = inrow2 + p2[j];
- out[0] = ( pix1[0] + pix2[0] + pix3[0] + pix4[0] ) >> 2;
- out[1] = ( pix1[1] + pix2[1] + pix3[1] + pix4[1] ) >> 2;
- out[2] = ( pix1[2] + pix2[2] + pix3[2] + pix4[2] ) >> 2;
- out[3] = ( pix1[3] + pix2[3] + pix3[3] + pix4[3] ) >> 2;
+ out[0] = (pix1[0] + pix2[0] + pix3[0] + pix4[0]) >> 2;
+ out[1] = (pix1[1] + pix2[1] + pix3[1] + pix4[1]) >> 2;
+ out[2] = (pix1[2] + pix2[2] + pix3[2] + pix4[2]) >> 2;
+ out[3] = (pix1[3] + pix2[3] + pix3[3] + pix4[3]) >> 2;
out += 4;
}
}
@@ -516,75 +532,80 @@ GL_MipMap
Operates in place, quartering the size of the texture
================
*/
-static void GL_MipMap( byte *in, int width, int height ) {
+static void GL_MipMap(byte *in, int width, int height)
+{
int i, j;
byte *out;
width <<= 2;
height >>= 1;
out = in;
- for( i = 0; i < height; i++, in += width ) {
- for( j = 0; j < width; j += 8, out += 4, in += 8 ) {
- out[0] = ( in[0] + in[4] + in[width+0] + in[width+4] ) >> 2;
- out[1] = ( in[1] + in[5] + in[width+1] + in[width+5] ) >> 2;
- out[2] = ( in[2] + in[6] + in[width+2] + in[width+6] ) >> 2;
- out[3] = ( in[3] + in[7] + in[width+3] + in[width+7] ) >> 2;
+ for (i = 0; i < height; i++, in += width) {
+ for (j = 0; j < width; j += 8, out += 4, in += 8) {
+ out[0] = (in[0] + in[4] + in[width + 0] + in[width + 4]) >> 2;
+ out[1] = (in[1] + in[5] + in[width + 1] + in[width + 5]) >> 2;
+ out[2] = (in[2] + in[6] + in[width + 2] + in[width + 6]) >> 2;
+ out[3] = (in[3] + in[7] + in[width + 3] + in[width + 7]) >> 2;
}
}
}
// returns true if image should not be bilinear filtered
// (useful for small images in scarp, charsets, etc)
-static inline qboolean is_nearest( void ) {
- if( gls.texnum[gls.tmu] == TEXNUM_SCRAP && gl_bilerp_pics->integer <= 1 ) {
+static inline qboolean is_nearest(void)
+{
+ if (gls.texnum[gls.tmu] == TEXNUM_SCRAP && gl_bilerp_pics->integer <= 1) {
return qtrue; // hack for scrap texture
}
- if( !upload_image ) {
+ if (!upload_image) {
return qfalse;
}
- if( upload_image->type == it_charset ) {
+ if (upload_image->type == it_charset) {
return !gl_bilerp_chars->integer;
}
- if( upload_image->type == it_pic ) {
+ if (upload_image->type == it_pic) {
return !gl_bilerp_pics->integer;
}
return qfalse;
}
-static inline qboolean is_wall( void ) {
- if( !upload_image ) {
+static inline qboolean is_wall(void)
+{
+ if (!upload_image) {
return qfalse;
}
- if( upload_image->type != it_wall ) {
+ if (upload_image->type != it_wall) {
return qfalse; // not a wall texture
}
- if( !upload_texinfo ) {
+ if (!upload_texinfo) {
return qtrue; // don't know what type of surface it is
- }
- if( upload_texinfo->c.flags & (SURF_SKY|SURF_WARP) ) {
+ }
+ if (upload_texinfo->c.flags & (SURF_SKY | SURF_WARP)) {
return qfalse; // don't grayscale or invert sky and liquid surfaces
}
return qtrue;
}
-static inline qboolean is_downsample( void ) {
- if( !upload_image ) {
+static inline qboolean is_downsample(void)
+{
+ if (!upload_image) {
return qtrue;
}
- if( upload_image->type != it_skin ) {
+ if (upload_image->type != it_skin) {
return qtrue; // not a skin
}
return !!gl_downsample_skins->integer;
}
-static inline qboolean is_alpha( byte *data, int width, int height ) {
+static inline qboolean is_alpha(byte *data, int width, int height)
+{
int i, c;
byte *scan;
c = width * height;
scan = data + 3;
- for( i = 0; i < c; i++, scan += 4 ) {
- if( *scan != 255 ) {
+ for (i = 0; i < c; i++, scan += 4) {
+ if (*scan != 255) {
return qtrue;
}
}
@@ -597,7 +618,8 @@ static inline qboolean is_alpha( byte *data, int width, int height ) {
GL_Upload32
===============
*/
-static qboolean GL_Upload32( byte *data, int width, int height, qboolean mipmap ) {
+static qboolean GL_Upload32(byte *data, int width, int height, qboolean mipmap)
+{
byte *scaled;
int scaled_width, scaled_height;
int comp;
@@ -605,20 +627,20 @@ static qboolean GL_Upload32( byte *data, int width, int height, qboolean mipmap
int maxsize;
// find the next-highest power of two
- scaled_width = npot32( width );
- scaled_height = npot32( height );
+ scaled_width = npot32(width);
+ scaled_height = npot32(height);
// save the flag indicating if costly resampling can be avoided
picmip = scaled_width == width && scaled_height == height;
maxsize = gl_config.maxTextureSize;
- if( mipmap && is_downsample() ) {
+ if (mipmap && is_downsample()) {
// round world textures down, if requested
- if( gl_round_down->integer ) {
- if( scaled_width > width )
+ if (gl_round_down->integer) {
+ if (scaled_width > width)
scaled_width >>= 1;
- if( scaled_height > height )
+ if (scaled_height > height)
scaled_height >>= 1;
}
@@ -626,23 +648,23 @@ static qboolean GL_Upload32( byte *data, int width, int height, qboolean mipmap
scaled_width >>= gl_picmip->integer;
scaled_height >>= gl_picmip->integer;
- if( gl_maxmip->integer > 0 ) {
- maxsize = 1 << Cvar_ClampInteger( gl_maxmip, 1, 12 );
- if( maxsize > gl_config.maxTextureSize ) {
+ if (gl_maxmip->integer > 0) {
+ maxsize = 1 << Cvar_ClampInteger(gl_maxmip, 1, 12);
+ if (maxsize > gl_config.maxTextureSize) {
maxsize = gl_config.maxTextureSize;
}
}
}
// don't ever bother with >256 textures
- while( scaled_width > maxsize || scaled_height > maxsize ) {
+ while (scaled_width > maxsize || scaled_height > maxsize) {
scaled_width >>= 1;
scaled_height >>= 1;
}
- if( scaled_width < 1 )
+ if (scaled_width < 1)
scaled_width = 1;
- if( scaled_height < 1 )
+ if (scaled_height < 1)
scaled_height = 1;
upload_width = scaled_width;
@@ -650,86 +672,85 @@ static qboolean GL_Upload32( byte *data, int width, int height, qboolean mipmap
// set colorscale and lightscale before mipmap
comp = gl_tex_solid_format;
- if( is_wall() && colorscale != 1 ) {
- GL_GrayScaleTexture( data, width, height );
- if( colorscale == 0 ) {
+ if (is_wall() && colorscale != 1) {
+ GL_GrayScaleTexture(data, width, height);
+ if (colorscale == 0) {
comp = GL_LUMINANCE;
}
}
- if( !( r_config.flags & QVF_GAMMARAMP ) &&
- ( mipmap || gl_gamma_scale_pics->integer ) )
- {
- GL_LightScaleTexture( data, width, height, mipmap );
+ if (!(r_config.flags & QVF_GAMMARAMP) &&
+ (mipmap || gl_gamma_scale_pics->integer)) {
+ GL_LightScaleTexture(data, width, height, mipmap);
}
- if( is_wall() && gl_invert->integer ) {
- GL_ColorInvertTexture( data, width, height );
+ if (is_wall() && gl_invert->integer) {
+ GL_ColorInvertTexture(data, width, height);
}
- if( scaled_width == width && scaled_height == height ) {
+ if (scaled_width == width && scaled_height == height) {
// optimized case, do nothing
scaled = data;
- } else if( picmip ) {
+ } else if (picmip) {
// optimized case, use faster mipmap operation
scaled = data;
- while( width > scaled_width || height > scaled_height ) {
- GL_MipMap( scaled, width, height );
+ while (width > scaled_width || height > scaled_height) {
+ GL_MipMap(scaled, width, height);
width >>= 1;
height >>= 1;
}
} else {
- scaled = FS_AllocTempMem( scaled_width * scaled_height * 4 );
- GL_ResampleTexture( data, width, height, scaled,
- scaled_width, scaled_height );
+ scaled = FS_AllocTempMem(scaled_width * scaled_height * 4);
+ GL_ResampleTexture(data, width, height, scaled,
+ scaled_width, scaled_height);
}
// scan the texture for any non-255 alpha
- isalpha = is_alpha( scaled, scaled_width, scaled_height );
- if( isalpha ) {
+ isalpha = is_alpha(scaled, scaled_width, scaled_height);
+ if (isalpha) {
comp = gl_tex_alpha_format;
}
- qglTexImage2D( GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, scaled );
+ qglTexImage2D(GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, scaled);
c.texUploads++;
- if( mipmap ) {
+ if (mipmap) {
int miplevel = 0;
- while( scaled_width > 1 || scaled_height > 1 ) {
- GL_MipMap( scaled, scaled_width, scaled_height );
+ while (scaled_width > 1 || scaled_height > 1) {
+ GL_MipMap(scaled, scaled_width, scaled_height);
scaled_width >>= 1;
scaled_height >>= 1;
- if( scaled_width < 1 )
+ if (scaled_width < 1)
scaled_width = 1;
- if( scaled_height < 1 )
+ if (scaled_height < 1)
scaled_height = 1;
miplevel++;
- qglTexImage2D( GL_TEXTURE_2D, miplevel, comp, scaled_width,
- scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled );
+ qglTexImage2D(GL_TEXTURE_2D, miplevel, comp, scaled_width,
+ scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled);
}
}
- if( mipmap ) {
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max );
-
- if( gl_config.maxAnisotropy >= 2 ) {
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,
- gl_filter_anisotropy );
+ if (mipmap) {
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
+
+ if (gl_config.maxAnisotropy >= 2) {
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,
+ gl_filter_anisotropy);
}
- } else if( is_nearest() ) {
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+ } else if (is_nearest()) {
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
} else {
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
-
- if( scaled != data ) {
- FS_FreeTempMem( scaled );
+
+ if (scaled != data) {
+ FS_FreeTempMem(scaled);
}
return isalpha;
@@ -742,35 +763,36 @@ GL_Upload8
Returns has_alpha
===============
*/
-static qboolean GL_Upload8( byte *data, int width, int height, qboolean mipmap ) {
- byte buffer[MAX_PALETTED_PIXELS*4];
+static qboolean GL_Upload8(byte *data, int width, int height, qboolean mipmap)
+{
+ byte buffer[MAX_PALETTED_PIXELS * 4];
byte *dest;
int i, s;
int p;
s = width * height;
- if( s > MAX_PALETTED_PIXELS ) {
+ if (s > MAX_PALETTED_PIXELS) {
// should never happen
- Com_Error( ERR_FATAL, "GL_Upload8: too large" );
+ Com_Error(ERR_FATAL, "GL_Upload8: too large");
}
dest = buffer;
- for( i = 0; i < s; i++ ) {
+ for (i = 0; i < s; i++) {
p = data[i];
- *( uint32_t * )dest = d_8to24table[p];
+ *(uint32_t *)dest = d_8to24table[p];
- if (p == 255) {
+ if (p == 255) {
// transparent, so scan around for another color
// to avoid alpha fringes
// FIXME: do a full flood fill so mips work...
- if (i > width && data[i-width] != 255)
- p = data[i-width];
- else if (i < s-width && data[i+width] != 255)
- p = data[i+width];
- else if (i > 0 && data[i-1] != 255)
- p = data[i-1];
- else if (i < s-1 && data[i+1] != 255)
- p = data[i+1];
+ if (i > width && data[i - width] != 255)
+ p = data[i - width];
+ else if (i < s - width && data[i + width] != 255)
+ p = data[i + width];
+ else if (i > 0 && data[i - 1] != 255)
+ p = data[i - 1];
+ else if (i < s - 1 && data[i + 1] != 255)
+ p = data[i + 1];
else
p = 0;
// copy rgb components
@@ -782,7 +804,7 @@ static qboolean GL_Upload8( byte *data, int width, int height, qboolean mipmap )
dest += 4;
}
- return GL_Upload32( buffer, width, height, mipmap );
+ return GL_Upload32(buffer, width, height, mipmap);
}
@@ -791,28 +813,28 @@ static qboolean GL_Upload8( byte *data, int width, int height, qboolean mipmap )
IMG_Load
================
*/
-void IMG_Load( image_t *image, byte *pic, int width, int height ) {
+void IMG_Load(image_t *image, byte *pic, int width, int height)
+{
qboolean mipmap, transparent;
byte *src, *dst, *ptr;
int i, j, s, t;
- if( !pic ) {
- Com_Error( ERR_FATAL, "%s: NULL", __func__ );
+ if (!pic) {
+ Com_Error(ERR_FATAL, "%s: NULL", __func__);
}
upload_image = image;
// load small 8-bit pics onto the scrap
- if( image->type == it_pic && ( image->flags & if_paletted ) &&
- width < 64 && height < 64 && !gl_noscrap->integer )
- {
- if( Scrap_AllocBlock( width, height, &s, &t ) ) {
+ if (image->type == it_pic && (image->flags & if_paletted) &&
+ width < 64 && height < 64 && !gl_noscrap->integer) {
+ if (Scrap_AllocBlock(width, height, &s, &t)) {
src = pic;
dst = &scrap_data[t * SCRAP_BLOCK_WIDTH + s];
- for( i = 0; i < height; i++ ) {
+ for (i = 0; i < height; i++) {
ptr = dst;
- for( j = 0; j < width; j++ ) {
- *ptr++ = *src++;
+ for (j = 0; j < width; j++) {
+ *ptr++ = *src++;
}
dst += SCRAP_BLOCK_WIDTH;
}
@@ -821,13 +843,13 @@ void IMG_Load( image_t *image, byte *pic, int width, int height ) {
image->upload_width = width;
image->upload_height = height;
image->flags |= if_scrap | if_transparent;
- image->sl = ( s + 0.01f ) / ( float )SCRAP_BLOCK_WIDTH;
- image->sh = ( s + width - 0.01f ) / ( float )SCRAP_BLOCK_WIDTH;
- image->tl = ( t + 0.01f ) / ( float )SCRAP_BLOCK_HEIGHT;
- image->th = ( t + height - 0.01f ) / ( float )SCRAP_BLOCK_HEIGHT;
+ image->sl = (s + 0.01f) / (float)SCRAP_BLOCK_WIDTH;
+ image->sh = (s + width - 0.01f) / (float)SCRAP_BLOCK_WIDTH;
+ image->tl = (t + 0.01f) / (float)SCRAP_BLOCK_HEIGHT;
+ image->th = (t + height - 0.01f) / (float)SCRAP_BLOCK_HEIGHT;
scrap_dirty = qtrue;
- if( !gl_static.registering ) {
+ if (!gl_static.registering) {
Scrap_Upload();
}
@@ -836,18 +858,18 @@ void IMG_Load( image_t *image, byte *pic, int width, int height ) {
}
}
- if( image->type == it_skin && ( image->flags & if_paletted ) )
- R_FloodFillSkin( pic, width, height );
+ if (image->type == it_skin && (image->flags & if_paletted))
+ R_FloodFillSkin(pic, width, height);
- mipmap = ( image->type == it_wall || image->type == it_skin );
- image->texnum = ( image - r_images );
- GL_BindTexture( image->texnum );
- if( image->flags & if_paletted ) {
- transparent = GL_Upload8( pic, width, height, mipmap );
+ mipmap = (image->type == it_wall || image->type == it_skin);
+ image->texnum = (image - r_images);
+ GL_BindTexture(image->texnum);
+ if (image->flags & if_paletted) {
+ transparent = GL_Upload8(pic, width, height, mipmap);
} else {
- transparent = GL_Upload32( pic, width, height, mipmap );
+ transparent = GL_Upload32(pic, width, height, mipmap);
}
- if( transparent ) {
+ if (transparent) {
image->flags |= if_transparent;
}
image->upload_width = upload_width; // after power of 2 and scales
@@ -860,41 +882,44 @@ void IMG_Load( image_t *image, byte *pic, int width, int height ) {
upload_image = NULL;
}
-void IMG_Unload( image_t *image ) {
- if( image->texnum > 0 && image->texnum < MAX_RIMAGES ) {
- qglDeleteTextures( 1, &image->texnum );
+void IMG_Unload(image_t *image)
+{
+ if (image->texnum > 0 && image->texnum < MAX_RIMAGES) {
+ qglDeleteTextures(1, &image->texnum);
image->texnum = 0;
}
}
-static void GL_BuildIntensityTable( void ) {
+static void GL_BuildIntensityTable(void)
+{
int i, j;
float f;
- f = Cvar_ClampValue( gl_intensity, 1, 5 );
+ f = Cvar_ClampValue(gl_intensity, 1, 5);
gl_static.inverse_intensity = 1 / f;
- for( i = 0; i < 256; i++ ) {
+ for (i = 0; i < 256; i++) {
j = i * f;
- if( j > 255 ) {
+ if (j > 255) {
j = 255;
}
intensitytable[i] = j;
}
}
-static void GL_BuildGammaTables( void ) {
+static void GL_BuildGammaTables(void)
+{
int i;
float inf, g = gl_gamma->value;
- if( g == 1.0f ) {
- for( i = 0; i < 256; i++ ) {
+ if (g == 1.0f) {
+ for (i = 0; i < 256; i++) {
gammatable[i] = i;
gammaintensitytable[i] = intensitytable[i];
}
} else {
- for( i = 0; i < 256; i++ ) {
- inf = 255 * pow( ( i + 0.5 ) / 255.5, g ) + 0.5;
- if( inf > 255 ) {
+ for (i = 0; i < 256; i++) {
+ inf = 255 * pow((i + 0.5) / 255.5, g) + 0.5;
+ if (inf > 255) {
inf = 255;
}
gammatable[i] = inf;
@@ -903,32 +928,34 @@ static void GL_BuildGammaTables( void ) {
}
}
-static void gl_gamma_changed( cvar_t *self ) {
+static void gl_gamma_changed(cvar_t *self)
+{
GL_BuildGammaTables();
- VID_UpdateGamma( gammatable );
+ VID_UpdateGamma(gammatable);
}
static const byte dottexture[8][8] = {
- {0,0,0,0,0,0,0,0},
- {0,0,1,1,0,0,0,0},
- {0,1,1,1,1,0,0,0},
- {0,1,1,1,1,0,0,0},
- {0,0,1,1,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
+ {0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 1, 1, 0, 0, 0, 0},
+ {0, 1, 1, 1, 1, 0, 0, 0},
+ {0, 1, 1, 1, 1, 0, 0, 0},
+ {0, 0, 1, 1, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0},
};
-static void GL_InitDefaultTexture( void ) {
+static void GL_InitDefaultTexture(void)
+{
int i, j;
- byte pixels[8*8*4];
+ byte pixels[8 * 8 * 4];
byte *dst;
image_t *ntx;
dst = pixels;
- for( i = 0; i < 8; i++ ) {
- for( j = 0; j < 8; j++ ) {
- dst[0] = dottexture[ i & 3 ][ j & 3 ] * 255;
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < 8; j++) {
+ dst[0] = dottexture[i & 3][j & 3] * 255;
dst[1] = 0;
dst[2] = 0;
dst[3] = 255;
@@ -936,8 +963,8 @@ static void GL_InitDefaultTexture( void ) {
}
}
- GL_BindTexture( TEXNUM_DEFAULT );
- GL_Upload32( pixels, 8, 8, qtrue );
+ GL_BindTexture(TEXNUM_DEFAULT);
+ GL_Upload32(pixels, 8, 8, qtrue);
// fill in notexture image
ntx = R_NOTEXTURE;
@@ -952,72 +979,75 @@ static void GL_InitDefaultTexture( void ) {
ntx->th = 1;
}
-static void GL_InitParticleTexture( void ) {
- byte pixels[16*16*4];
+static void GL_InitParticleTexture(void)
+{
+ byte pixels[16 * 16 * 4];
byte *dst;
float x, y, f;
int i, j;
dst = pixels;
- for( i = 0; i < 16; i++ ) {
- for( j = 0; j < 16; j++ ) {
- x = j - 16/2 + 0.5f;
- y = i - 16/2 + 0.5f;
- f = sqrt( x * x + y * y );
- f = 1.0f - f / ( 16/2 - 0.5f );
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < 16; j++) {
+ x = j - 16 / 2 + 0.5f;
+ y = i - 16 / 2 + 0.5f;
+ f = sqrt(x * x + y * y);
+ f = 1.0f - f / (16 / 2 - 0.5f);
dst[0] = 255;
dst[1] = 255;
dst[2] = 255;
- dst[3] = 255 * clamp( f, 0, 1 );
+ dst[3] = 255 * clamp(f, 0, 1);
dst += 4;
}
}
- GL_BindTexture( TEXNUM_PARTICLE );
- GL_Upload32( pixels, 16, 16, qfalse );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
+ GL_BindTexture(TEXNUM_PARTICLE);
+ GL_Upload32(pixels, 16, 16, qfalse);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
}
-static void GL_InitWhiteImage( void ) {
+static void GL_InitWhiteImage(void)
+{
uint32_t pixel;
pixel = U32_WHITE;
- GL_BindTexture( TEXNUM_WHITE );
- GL_Upload32( ( byte * )&pixel, 1, 1, qfalse );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+ GL_BindTexture(TEXNUM_WHITE);
+ GL_Upload32((byte *)&pixel, 1, 1, qfalse);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
pixel = U32_BLACK;
- GL_BindTexture( TEXNUM_BLACK );
- GL_Upload32( ( byte * )&pixel, 1, 1, qfalse );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+ GL_BindTexture(TEXNUM_BLACK);
+ GL_Upload32((byte *)&pixel, 1, 1, qfalse);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
-static void GL_InitBeamTexture( void ) {
- byte pixels[16*16*4];
+static void GL_InitBeamTexture(void)
+{
+ byte pixels[16 * 16 * 4];
byte *dst;
float f;
int i, j;
dst = pixels;
- for( i = 0; i < 16; i++ ) {
- for( j = 0; j < 16; j++ ) {
- f = abs( j - 16/2 ) - 0.5f;
- f = 1.0f - f / ( 16/2 - 2.5f );
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < 16; j++) {
+ f = abs(j - 16 / 2) - 0.5f;
+ f = 1.0f - f / (16 / 2 - 2.5f);
dst[0] = 255;
dst[1] = 255;
dst[2] = 255;
- dst[3] = 255 * clamp( f, 0, 1 );
+ dst[3] = 255 * clamp(f, 0, 1);
dst += 4;
}
}
-
- GL_BindTexture( TEXNUM_BEAM );
- GL_Upload32( pixels, 16, 16, qfalse );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
- qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+
+ GL_BindTexture(TEXNUM_BEAM);
+ GL_Upload32(pixels, 16, 16, qfalse);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
/*
@@ -1025,38 +1055,39 @@ static void GL_InitBeamTexture( void ) {
GL_InitImages
===============
*/
-void GL_InitImages( void ) {
- gl_bilerp_chars = Cvar_Get( "gl_bilerp_chars", "0", 0 );
+void GL_InitImages(void)
+{
+ gl_bilerp_chars = Cvar_Get("gl_bilerp_chars", "0", 0);
gl_bilerp_chars->changed = gl_bilerp_chars_changed;
- gl_bilerp_pics = Cvar_Get( "gl_bilerp_pics", "1", 0 );
+ gl_bilerp_pics = Cvar_Get("gl_bilerp_pics", "1", 0);
gl_bilerp_pics->changed = gl_bilerp_pics_changed;
- gl_texturemode = Cvar_Get( "gl_texturemode",
- "GL_LINEAR_MIPMAP_LINEAR", CVAR_ARCHIVE );
+ gl_texturemode = Cvar_Get("gl_texturemode",
+ "GL_LINEAR_MIPMAP_LINEAR", CVAR_ARCHIVE);
gl_texturemode->changed = gl_texturemode_changed;
gl_texturemode->generator = gl_texturemode_g;
- gl_anisotropy = Cvar_Get( "gl_anisotropy", "1", 0 );
+ gl_anisotropy = Cvar_Get("gl_anisotropy", "1", 0);
gl_anisotropy->changed = gl_anisotropy_changed;
- gl_noscrap = Cvar_Get( "gl_noscrap", "0", CVAR_FILES );
- gl_round_down = Cvar_Get( "gl_round_down", "0", CVAR_FILES );
- gl_picmip = Cvar_Get( "gl_picmip", "0", CVAR_FILES );
- gl_maxmip = Cvar_Get( "gl_maxmip", "0", CVAR_FILES );
- gl_downsample_skins = Cvar_Get( "gl_downsample_skins", "1", CVAR_FILES );
- gl_gamma_scale_pics = Cvar_Get( "gl_gamma_scale_pics", "0", CVAR_FILES );
- gl_texturealphamode = Cvar_Get( "gl_texturealphamode",
- "default", CVAR_ARCHIVE|CVAR_FILES );
+ gl_noscrap = Cvar_Get("gl_noscrap", "0", CVAR_FILES);
+ gl_round_down = Cvar_Get("gl_round_down", "0", CVAR_FILES);
+ gl_picmip = Cvar_Get("gl_picmip", "0", CVAR_FILES);
+ gl_maxmip = Cvar_Get("gl_maxmip", "0", CVAR_FILES);
+ gl_downsample_skins = Cvar_Get("gl_downsample_skins", "1", CVAR_FILES);
+ gl_gamma_scale_pics = Cvar_Get("gl_gamma_scale_pics", "0", CVAR_FILES);
+ gl_texturealphamode = Cvar_Get("gl_texturealphamode",
+ "default", CVAR_ARCHIVE | CVAR_FILES);
gl_texturealphamode->generator = gl_texturealphamode_g;
- gl_texturesolidmode = Cvar_Get( "gl_texturesolidmode",
- "default", CVAR_ARCHIVE|CVAR_FILES );
+ gl_texturesolidmode = Cvar_Get("gl_texturesolidmode",
+ "default", CVAR_ARCHIVE | CVAR_FILES);
gl_texturesolidmode->generator = gl_texturesolidmode_g;
- gl_saturation = Cvar_Get( "gl_saturation", "1", CVAR_FILES );
- gl_intensity = Cvar_Get( "intensity", "1", CVAR_FILES );
- gl_invert = Cvar_Get( "gl_invert", "0", CVAR_FILES );
- if( r_config.flags & QVF_GAMMARAMP ) {
- gl_gamma = Cvar_Get( "vid_gamma", "1", CVAR_ARCHIVE );
+ gl_saturation = Cvar_Get("gl_saturation", "1", CVAR_FILES);
+ gl_intensity = Cvar_Get("intensity", "1", CVAR_FILES);
+ gl_invert = Cvar_Get("gl_invert", "0", CVAR_FILES);
+ if (r_config.flags & QVF_GAMMARAMP) {
+ gl_gamma = Cvar_Get("vid_gamma", "1", CVAR_ARCHIVE);
gl_gamma->changed = gl_gamma_changed;
gl_gamma->flags &= ~CVAR_FILES;
} else {
- gl_gamma = Cvar_Get( "vid_gamma", "1", CVAR_ARCHIVE|CVAR_FILES );
+ gl_gamma = Cvar_Get("vid_gamma", "1", CVAR_ARCHIVE | CVAR_FILES);
}
IMG_Init();
@@ -1065,22 +1096,22 @@ void GL_InitImages( void ) {
GL_BuildIntensityTable();
- if( r_config.flags & QVF_GAMMARAMP ) {
- gl_gamma_changed( gl_gamma );
+ if (r_config.flags & QVF_GAMMARAMP) {
+ gl_gamma_changed(gl_gamma);
} else {
GL_BuildGammaTables();
}
// FIXME: the name 'saturation' is misleading in this context
- colorscale = Cvar_ClampValue( gl_saturation, 0, 1 );
+ colorscale = Cvar_ClampValue(gl_saturation, 0, 1);
GL_TextureAlphaMode();
GL_TextureSolidMode();
- gl_texturemode_changed( gl_texturemode );
- gl_anisotropy_changed( gl_anisotropy );
- gl_bilerp_chars_changed( gl_bilerp_chars );
- gl_bilerp_pics_changed( gl_bilerp_pics );
+ gl_texturemode_changed(gl_texturemode);
+ gl_anisotropy_changed(gl_anisotropy);
+ gl_bilerp_chars_changed(gl_bilerp_chars);
+ gl_bilerp_pics_changed(gl_bilerp_pics);
upload_image = NULL;
upload_texinfo = NULL;
@@ -1102,7 +1133,8 @@ extern image_t *r_charset;
GL_ShutdownImages
===============
*/
-void GL_ShutdownImages( void ) {
+void GL_ShutdownImages(void)
+{
GLuint texnums[NUM_TEXNUMS];
int i, j;
@@ -1116,11 +1148,11 @@ void GL_ShutdownImages( void ) {
gl_gamma->changed = NULL;
// unbind everything
- qglActiveTextureARB( GL_TEXTURE1_ARB );
- qglBindTexture( GL_TEXTURE_2D, 0 );
- qglActiveTextureARB( GL_TEXTURE0_ARB );
- qglBindTexture( GL_TEXTURE_2D, 0 );
- for( i = 0; i < MAX_TMUS; i++ ) {
+ qglActiveTextureARB(GL_TEXTURE1_ARB);
+ qglBindTexture(GL_TEXTURE_2D, 0);
+ qglActiveTextureARB(GL_TEXTURE0_ARB);
+ qglBindTexture(GL_TEXTURE_2D, 0);
+ for (i = 0; i < MAX_TMUS; i++) {
gls.texnum[i] = 0;
gls.texenv[i] = 0;
}
@@ -1128,10 +1160,10 @@ void GL_ShutdownImages( void ) {
// delete auto textures
j = TEXNUM_LIGHTMAP + lm.highwater - TEXNUM_DEFAULT;
- for( i = 0; i < j; i++ ) {
+ for (i = 0; i < j; i++) {
texnums[i] = TEXNUM_DEFAULT + i;
}
- qglDeleteTextures( j, texnums );
+ qglDeleteTextures(j, texnums);
lm.highwater = 0;