vkQuake2 doxygen  1.0 dev
gl_image.c File Reference
#include "gl_local.h"

Go to the source code of this file.

Classes

struct  glmode_t
 
struct  gltmode_t
 
struct  _TargaHeader
 
struct  floodfill_t
 

Macros

#define NUM_GL_MODES   (sizeof(modes) / sizeof (glmode_t))
 
#define NUM_GL_ALPHA_MODES   (sizeof(gl_alpha_modes) / sizeof (gltmode_t))
 
#define NUM_GL_SOLID_MODES   (sizeof(gl_solid_modes) / sizeof (gltmode_t))
 
#define MAX_SCRAPS   1
 
#define BLOCK_WIDTH   256
 
#define BLOCK_HEIGHT   256
 
#define FLOODFILL_FIFO_SIZE   0x1000
 
#define FLOODFILL_FIFO_MASK   (FLOODFILL_FIFO_SIZE - 1)
 
#define FLOODFILL_STEP(off, dx, dy)
 

Typedefs

typedef struct _TargaHeader TargaHeader
 

Functions

qboolean GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboolean is_sky)
 
qboolean GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap)
 
void GL_SetTexturePalette (unsigned palette[256])
 
void GL_EnableMultitexture (qboolean enable)
 
void GL_SelectTexture (GLenum texture)
 
void GL_TexEnv (GLenum mode)
 
void GL_Bind (int texnum)
 
void GL_MBind (GLenum target, int texnum)
 
void GL_TextureMode (char *string)
 
void GL_TextureAlphaMode (char *string)
 
void GL_TextureSolidMode (char *string)
 
void GL_ImageList_f (void)
 
int Scrap_AllocBlock (int w, int h, int *x, int *y)
 
void Scrap_Upload (void)
 
void LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height)
 
void LoadTGA (char *name, byte **pic, int *width, int *height)
 
void R_FloodFillSkin (byte *skin, int skinwidth, int skinheight)
 
void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight)
 
void GL_LightScaleTexture (unsigned *in, int inwidth, int inheight, qboolean only_gamma)
 
void GL_MipMap (byte *in, int width, int height)
 
void GL_BuildPalettedTexture (unsigned char *paletted_texture, unsigned char *scaled, int scaled_width, int scaled_height)
 
image_tGL_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type, int bits)
 
image_tGL_LoadWal (char *name)
 
image_tGL_FindImage (char *name, imagetype_t type)
 
struct image_sR_RegisterSkin (char *name)
 
void GL_FreeUnusedImages (void)
 
int Draw_GetPalette (void)
 
void GL_InitImages (void)
 
void GL_ShutdownImages (void)
 

Variables

image_t gltextures [MAX_GLTEXTURES]
 
int numgltextures
 
int base_textureid
 
static byte intensitytable [256]
 
static unsigned char gammatable [256]
 
cvar_tintensity
 
unsigned d_8to24table [256]
 
int gl_solid_format = 3
 
int gl_alpha_format = 4
 
int gl_tex_solid_format = 3
 
int gl_tex_alpha_format = 4
 
int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST
 
int gl_filter_max = GL_LINEAR
 
glmode_t modes []
 
gltmode_t gl_alpha_modes []
 
gltmode_t gl_solid_modes []
 
int scrap_allocated [MAX_SCRAPS][BLOCK_WIDTH]
 
byte scrap_texels [MAX_SCRAPS][BLOCK_WIDTH *BLOCK_HEIGHT]
 
qboolean scrap_dirty
 
int scrap_uploads
 
int upload_width
 
int upload_height
 
qboolean uploaded_paletted
 

Macro Definition Documentation

◆ BLOCK_HEIGHT

#define BLOCK_HEIGHT   256

Definition at line 361 of file gl_image.c.

◆ BLOCK_WIDTH

#define BLOCK_WIDTH   256

Definition at line 360 of file gl_image.c.

◆ FLOODFILL_FIFO_MASK

#define FLOODFILL_FIFO_MASK   (FLOODFILL_FIFO_SIZE - 1)

Definition at line 760 of file gl_image.c.

◆ FLOODFILL_FIFO_SIZE

#define FLOODFILL_FIFO_SIZE   0x1000

Definition at line 759 of file gl_image.c.

◆ FLOODFILL_STEP

#define FLOODFILL_STEP (   off,
  dx,
  dy 
)
Value:
{ \
if (pos[off] == fillcolor) \
{ \
pos[off] = 255; \
fifo[inpt].x = x + (dx), fifo[inpt].y = y + (dy); \
inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; \
} \
else if (pos[off] != 255) fdc = pos[off]; \
}

Definition at line 762 of file gl_image.c.

◆ MAX_SCRAPS

#define MAX_SCRAPS   1

Definition at line 359 of file gl_image.c.

◆ NUM_GL_ALPHA_MODES

#define NUM_GL_ALPHA_MODES   (sizeof(gl_alpha_modes) / sizeof (gltmode_t))

Definition at line 197 of file gl_image.c.

◆ NUM_GL_MODES

#define NUM_GL_MODES   (sizeof(modes) / sizeof (glmode_t))

Definition at line 180 of file gl_image.c.

◆ NUM_GL_SOLID_MODES

#define NUM_GL_SOLID_MODES   (sizeof(gl_solid_modes) / sizeof (gltmode_t))

Definition at line 211 of file gl_image.c.

Typedef Documentation

◆ TargaHeader

typedef struct _TargaHeader TargaHeader

Function Documentation

◆ Draw_GetPalette()

int Draw_GetPalette ( void  )

Definition at line 1471 of file gl_image.c.

1472 {
1473  int i;
1474  int r, g, b;
1475  unsigned v;
1476  byte *pic, *pal;
1477  int width, height;
1478 
1479  // get the palette
1480 
1481  LoadPCX ("pics/colormap.pcx", &pic, &pal, &width, &height);
1482  if (!pal)
1483  ri.Sys_Error (ERR_FATAL, "Couldn't load pics/colormap.pcx");
1484 
1485  for (i=0 ; i<256 ; i++)
1486  {
1487  r = pal[i*3+0];
1488  g = pal[i*3+1];
1489  b = pal[i*3+2];
1490 
1491  v = (255<<24) + (r<<0) + (g<<8) + (b<<16);
1492  d_8to24table[i] = LittleLong(v);
1493  }
1494 
1495  d_8to24table[255] &= LittleLong(0xffffff); // 255 is transparent
1496 
1497  free (pic);
1498  free (pal);
1499 
1500  return 0;
1501 }

Referenced by GL_InitImages().

◆ GL_Bind()

void GL_Bind ( int  texnum)

◆ GL_BuildPalettedTexture()

void GL_BuildPalettedTexture ( unsigned char *  paletted_texture,
unsigned char *  scaled,
int  scaled_width,
int  scaled_height 
)

Definition at line 945 of file gl_image.c.

946 {
947  int i;
948 
949  for ( i = 0; i < scaled_width * scaled_height; i++ )
950  {
951  unsigned int r, g, b, c;
952 
953  r = ( scaled[0] >> 3 ) & 31;
954  g = ( scaled[1] >> 2 ) & 63;
955  b = ( scaled[2] >> 3 ) & 31;
956 
957  c = r | ( g << 5 ) | ( b << 11 );
958 
959  paletted_texture[i] = gl_state.d_16to8table[c];
960 
961  scaled += 4;
962  }
963 }

Referenced by GL_Upload32().

◆ GL_EnableMultitexture()

void GL_EnableMultitexture ( qboolean  enable)

Definition at line 71 of file gl_image.c.

72 {
73  if ( !qglSelectTextureSGIS && !qglActiveTextureARB )
74  return;
75 
76  if ( enable )
77  {
79  qglEnable( GL_TEXTURE_2D );
80  GL_TexEnv( GL_REPLACE );
81  }
82  else
83  {
85  qglDisable( GL_TEXTURE_2D );
86  GL_TexEnv( GL_REPLACE );
87  }
89  GL_TexEnv( GL_REPLACE );
90 }

Referenced by DrawTextureChains(), GL_BeginBuildingLightmaps(), GL_EndBuildingLightmaps(), R_DrawBrushModel(), R_DrawInlineBModel(), and R_DrawWorld().

◆ GL_FindImage()

image_t* GL_FindImage ( char *  name,
imagetype_t  type 
)

Definition at line 1363 of file gl_image.c.

1364 {
1365  image_t *image;
1366  int i, len;
1367  byte *pic, *palette;
1368  int width, height;
1369 
1370  if (!name)
1371  return NULL; // ri.Sys_Error (ERR_DROP, "GL_FindImage: NULL name");
1372  len = (int)strlen(name);
1373  if (len<5)
1374  return NULL; // ri.Sys_Error (ERR_DROP, "GL_FindImage: bad name: %s", name);
1375 
1376  // look for it
1377  for (i=0, image=gltextures ; i<numgltextures ; i++,image++)
1378  {
1379  if (!strcmp(name, image->name))
1380  {
1382  return image;
1383  }
1384  }
1385 
1386  //
1387  // load the pic from disk
1388  //
1389  pic = NULL;
1390  palette = NULL;
1391  if (!strcmp(name+len-4, ".pcx"))
1392  {
1393  LoadPCX (name, &pic, &palette, &width, &height);
1394  if (!pic)
1395  return NULL; // ri.Sys_Error (ERR_DROP, "GL_FindImage: can't load %s", name);
1396  image = GL_LoadPic (name, pic, width, height, type, 8);
1397  }
1398  else if (!strcmp(name+len-4, ".wal"))
1399  {
1400  image = GL_LoadWal (name);
1401  }
1402  else if (!strcmp(name+len-4, ".tga"))
1403  {
1404  LoadTGA (name, &pic, &width, &height);
1405  if (!pic)
1406  return NULL; // ri.Sys_Error (ERR_DROP, "GL_FindImage: can't load %s", name);
1407  image = GL_LoadPic (name, pic, width, height, type, 32);
1408  }
1409  else
1410  return NULL; // ri.Sys_Error (ERR_DROP, "GL_FindImage: bad extension on: %s", name);
1411 
1412 
1413  if (pic)
1414  free(pic);
1415  if (palette)
1416  free(palette);
1417 
1418  return image;
1419 }

Referenced by Draw_FindPic(), Draw_InitLocal(), Mod_LoadAliasModel(), Mod_LoadSpriteModel(), Mod_LoadTexinfo(), R_RegisterModel(), R_RegisterSkin(), and R_SetSky().

◆ GL_FreeUnusedImages()

void GL_FreeUnusedImages ( void  )

Definition at line 1442 of file gl_image.c.

1443 {
1444  int i;
1445  image_t *image;
1446 
1447  // never free r_notexture or particle texture
1450 
1451  for (i=0, image=gltextures ; i<numgltextures ; i++, image++)
1452  {
1454  continue; // used this sequence
1455  if (!image->registration_sequence)
1456  continue; // free image_t slot
1457  if (image->type == it_pic)
1458  continue; // don't free pics
1459  // free it
1460  qglDeleteTextures (1, &image->texnum);
1461  memset (image, 0, sizeof(*image));
1462  }
1463 }

Referenced by R_EndRegistration().

◆ GL_ImageList_f()

void GL_ImageList_f ( void  )

Definition at line 303 of file gl_image.c.

304 {
305  int i;
306  image_t *image;
307  int texels;
308  const char *palstrings[2] =
309  {
310  "RGB",
311  "PAL"
312  };
313 
314  ri.Con_Printf (PRINT_ALL, "------------------\n");
315  texels = 0;
316 
317  for (i=0, image=gltextures ; i<numgltextures ; i++, image++)
318  {
319  if (image->texnum <= 0)
320  continue;
321  texels += image->upload_width*image->upload_height;
322  switch (image->type)
323  {
324  case it_skin:
325  ri.Con_Printf (PRINT_ALL, "M");
326  break;
327  case it_sprite:
328  ri.Con_Printf (PRINT_ALL, "S");
329  break;
330  case it_wall:
331  ri.Con_Printf (PRINT_ALL, "W");
332  break;
333  case it_pic:
334  ri.Con_Printf (PRINT_ALL, "P");
335  break;
336  default:
337  ri.Con_Printf (PRINT_ALL, " ");
338  break;
339  }
340 
341  ri.Con_Printf (PRINT_ALL, " %3i %3i %s: %s\n",
342  image->upload_width, image->upload_height, palstrings[image->paletted], image->name);
343  }
344  ri.Con_Printf (PRINT_ALL, "Total texel count (not counting mipmaps): %i\n", texels);
345 }

Referenced by R_Register().

◆ GL_InitImages()

void GL_InitImages ( void  )

Definition at line 1509 of file gl_image.c.

1510 {
1511  int i, j;
1512  float g = vid_gamma->value;
1513 
1515 
1516  // init intensity conversions
1517  intensity = ri.Cvar_Get ("intensity", "2", 0);
1518 
1519  if ( intensity->value <= 1 )
1520  ri.Cvar_Set( "intensity", "1" );
1521 
1523 
1524  Draw_GetPalette ();
1525 
1526  if ( qglColorTableEXT )
1527  {
1528  ri.FS_LoadFile( "pics/16to8.dat", (void **)&gl_state.d_16to8table );
1529  if ( !gl_state.d_16to8table )
1530  ri.Sys_Error( ERR_FATAL, "Couldn't load pics/16to8.pcx");
1531  }
1532 
1534  {
1535  g = 1.0F;
1536  }
1537 
1538  for ( i = 0; i < 256; i++ )
1539  {
1540  if ( g == 1 )
1541  {
1542  gammatable[i] = i;
1543  }
1544  else
1545  {
1546  float inf;
1547 
1548  inf = 255 * pow ( (i+0.5)/255.5 , g ) + 0.5;
1549  if (inf < 0)
1550  inf = 0;
1551  if (inf > 255)
1552  inf = 255;
1553  gammatable[i] = inf;
1554  }
1555  }
1556 
1557  for (i=0 ; i<256 ; i++)
1558  {
1559  j = i*intensity->value;
1560  if (j > 255)
1561  j = 255;
1562  intensitytable[i] = j;
1563  }
1564 }

Referenced by R_Init().

◆ GL_LightScaleTexture()

void GL_LightScaleTexture ( unsigned *  in,
int  inwidth,
int  inheight,
qboolean  only_gamma 
)

Definition at line 877 of file gl_image.c.

878 {
879  if ( only_gamma )
880  {
881  int i, c;
882  byte *p;
883 
884  p = (byte *)in;
885 
886  c = inwidth*inheight;
887  for (i=0 ; i<c ; i++, p+=4)
888  {
889  p[0] = gammatable[p[0]];
890  p[1] = gammatable[p[1]];
891  p[2] = gammatable[p[2]];
892  }
893  }
894  else
895  {
896  int i, c;
897  byte *p;
898 
899  p = (byte *)in;
900 
901  c = inwidth*inheight;
902  for (i=0 ; i<c ; i++, p+=4)
903  {
904  p[0] = gammatable[intensitytable[p[0]]];
905  p[1] = gammatable[intensitytable[p[1]]];
906  p[2] = gammatable[intensitytable[p[2]]];
907  }
908  }
909 }

Referenced by GL_Upload32().

◆ GL_LoadPic()

image_t* GL_LoadPic ( char *  name,
byte pic,
int  width,
int  height,
imagetype_t  type,
int  bits 
)

Definition at line 1247 of file gl_image.c.

1248 {
1249  image_t *image;
1250  int i;
1251 
1252  // find a free image_t
1253  for (i=0, image=gltextures ; i<numgltextures ; i++,image++)
1254  {
1255  if (!image->texnum)
1256  break;
1257  }
1258  if (i == numgltextures)
1259  {
1261  ri.Sys_Error (ERR_DROP, "MAX_GLTEXTURES");
1262  numgltextures++;
1263  }
1264  image = &gltextures[i];
1265 
1266  if (strlen(name) >= sizeof(image->name))
1267  ri.Sys_Error (ERR_DROP, "Draw_LoadPic: \"%s\" is too long", name);
1268  strcpy (image->name, name);
1270 
1271  image->width = width;
1272  image->height = height;
1273  image->type = type;
1274 
1275  if (type == it_skin && bits == 8)
1276  R_FloodFillSkin(pic, width, height);
1277 
1278  // load little pics into the scrap
1279  if (image->type == it_pic && bits == 8
1280  && image->width < 64 && image->height < 64)
1281  {
1282  int x, y;
1283  int i, j, k;
1284  int texnum;
1285 
1286  texnum = Scrap_AllocBlock (image->width, image->height, &x, &y);
1287  if (texnum == -1)
1288  goto nonscrap;
1289  scrap_dirty = true;
1290 
1291  // copy the texels into the scrap block
1292  k = 0;
1293  for (i=0 ; i<image->height ; i++)
1294  for (j=0 ; j<image->width ; j++, k++)
1295  scrap_texels[texnum][(y+i)*BLOCK_WIDTH + x + j] = pic[k];
1296  image->texnum = TEXNUM_SCRAPS + texnum;
1297  image->scrap = true;
1298  image->has_alpha = true;
1299  image->sl = (x+0.01)/(float)BLOCK_WIDTH;
1300  image->sh = (x+image->width-0.01)/(float)BLOCK_WIDTH;
1301  image->tl = (y+0.01)/(float)BLOCK_WIDTH;
1302  image->th = (y+image->height-0.01)/(float)BLOCK_WIDTH;
1303  }
1304  else
1305  {
1306 nonscrap:
1307  image->scrap = false;
1308  image->texnum = TEXNUM_IMAGES + (image - gltextures);
1309  GL_Bind(image->texnum);
1310  if (bits == 8)
1311  image->has_alpha = GL_Upload8 (pic, width, height, (image->type != it_pic && image->type != it_sky), image->type == it_sky );
1312  else
1313  image->has_alpha = GL_Upload32 ((unsigned *)pic, width, height, (image->type != it_pic && image->type != it_sky) );
1314  image->upload_width = upload_width; // after power of 2 and scales
1315  image->upload_height = upload_height;
1316  image->paletted = uploaded_paletted;
1317  image->sl = 0;
1318  image->sh = 1;
1319  image->tl = 0;
1320  image->th = 1;
1321  }
1322 
1323  return image;
1324 }

Referenced by GL_FindImage(), and GL_LoadWal().

◆ GL_LoadWal()

image_t* GL_LoadWal ( char *  name)

Definition at line 1332 of file gl_image.c.

1333 {
1334  miptex_t *mt;
1335  int width, height, ofs;
1336  image_t *image;
1337 
1338  ri.FS_LoadFile (name, (void **)&mt);
1339  if (!mt)
1340  {
1341  ri.Con_Printf (PRINT_ALL, "GL_FindImage: can't load %s\n", name);
1342  return r_notexture;
1343  }
1344 
1345  width = LittleLong (mt->width);
1346  height = LittleLong (mt->height);
1347  ofs = LittleLong (mt->offsets[0]);
1348 
1349  image = GL_LoadPic (name, (byte *)mt + ofs, width, height, it_wall, 8);
1350 
1351  ri.FS_FreeFile ((void *)mt);
1352 
1353  return image;
1354 }

Referenced by GL_FindImage().

◆ GL_MBind()

void GL_MBind ( GLenum  target,
int  texnum 
)

Definition at line 149 of file gl_image.c.

150 {
151  GL_SelectTexture( target );
152  if ( target == gl_texture0 )
153  {
154  if ( gl_state.currenttextures[0] == texnum )
155  return;
156  }
157  else
158  {
159  if ( gl_state.currenttextures[1] == texnum )
160  return;
161  }
162  GL_Bind( texnum );
163 }

Referenced by GL_RenderLightmappedPoly().

◆ GL_MipMap()

void GL_MipMap ( byte in,
int  width,
int  height 
)

Definition at line 918 of file gl_image.c.

919 {
920  int i, j;
921  byte *out;
922 
923  width <<=2;
924  height >>= 1;
925  out = in;
926  for (i=0 ; i<height ; i++, in+=width)
927  {
928  for (j=0 ; j<width ; j+=8, out+=4, in+=8)
929  {
930  out[0] = (in[0] + in[4] + in[width+0] + in[width+4])>>2;
931  out[1] = (in[1] + in[5] + in[width+1] + in[width+5])>>2;
932  out[2] = (in[2] + in[6] + in[width+2] + in[width+6])>>2;
933  out[3] = (in[3] + in[7] + in[width+3] + in[width+7])>>2;
934  }
935  }
936 }

Referenced by GL_Upload32().

◆ GL_ResampleTexture()

void GL_ResampleTexture ( unsigned *  in,
int  inwidth,
int  inheight,
unsigned *  out,
int  outwidth,
int  outheight 
)

Definition at line 827 of file gl_image.c.

828 {
829  int i, j;
830  unsigned *inrow, *inrow2;
831  unsigned frac, fracstep;
832  unsigned p1[1024], p2[1024];
833  byte *pix1, *pix2, *pix3, *pix4;
834 
835  fracstep = inwidth*0x10000/outwidth;
836 
837  frac = fracstep>>2;
838  for (i=0 ; i<outwidth ; i++)
839  {
840  p1[i] = 4*(frac>>16);
841  frac += fracstep;
842  }
843  frac = 3*(fracstep>>2);
844  for (i=0 ; i<outwidth ; i++)
845  {
846  p2[i] = 4*(frac>>16);
847  frac += fracstep;
848  }
849 
850  for (i=0 ; i<outheight ; i++, out += outwidth)
851  {
852  inrow = in + inwidth*(int)((i+0.25)*inheight/outheight);
853  inrow2 = in + inwidth*(int)((i+0.75)*inheight/outheight);
854  frac = fracstep >> 1;
855  for (j=0 ; j<outwidth ; j++)
856  {
857  pix1 = (byte *)inrow + p1[j];
858  pix2 = (byte *)inrow + p2[j];
859  pix3 = (byte *)inrow2 + p1[j];
860  pix4 = (byte *)inrow2 + p2[j];
861  ((byte *)(out+j))[0] = (pix1[0] + pix2[0] + pix3[0] + pix4[0])>>2;
862  ((byte *)(out+j))[1] = (pix1[1] + pix2[1] + pix3[1] + pix4[1])>>2;
863  ((byte *)(out+j))[2] = (pix1[2] + pix2[2] + pix3[2] + pix4[2])>>2;
864  ((byte *)(out+j))[3] = (pix1[3] + pix2[3] + pix3[3] + pix4[3])>>2;
865  }
866  }
867 }

Referenced by GL_Upload32().

◆ GL_SelectTexture()

void GL_SelectTexture ( GLenum  texture)

Definition at line 92 of file gl_image.c.

93 {
94  int tmu;
95 
96  if ( !qglSelectTextureSGIS && !qglActiveTextureARB )
97  return;
98 
99  if ( texture == gl_texture0 )
100  {
101  tmu = 0;
102  }
103  else
104  {
105  tmu = 1;
106  }
107 
108  if ( tmu == gl_state.currenttmu )
109  {
110  return;
111  }
112 
113  gl_state.currenttmu = tmu;
114 
115  if ( qglSelectTextureSGIS )
116  {
117  qglSelectTextureSGIS( texture );
118  }
119  else if ( qglActiveTextureARB )
120  {
121  qglActiveTextureARB( texture );
122  qglClientActiveTextureARB( texture );
123  }
124 }

Referenced by GL_BeginBuildingLightmaps(), GL_EnableMultitexture(), GL_MBind(), R_DrawBrushModel(), and R_DrawWorld().

◆ GL_SetTexturePalette()

void GL_SetTexturePalette ( unsigned  palette[256])

Definition at line 48 of file gl_image.c.

49 {
50  int i;
51  unsigned char temptable[768];
52 
53  if ( qglColorTableEXT && gl_ext_palettedtexture->value )
54  {
55  for ( i = 0; i < 256; i++ )
56  {
57  temptable[i*3+0] = ( palette[i] >> 0 ) & 0xff;
58  temptable[i*3+1] = ( palette[i] >> 8 ) & 0xff;
59  temptable[i*3+2] = ( palette[i] >> 16 ) & 0xff;
60  }
61 
62  qglColorTableEXT( GL_SHARED_TEXTURE_PALETTE_EXT,
63  GL_RGB,
64  256,
65  GL_RGB,
66  GL_UNSIGNED_BYTE,
67  temptable );
68  }
69 }

Referenced by GL_SetDefaultState(), and R_SetPalette().

◆ GL_ShutdownImages()

void GL_ShutdownImages ( void  )

Definition at line 1571 of file gl_image.c.

1572 {
1573  int i;
1574  image_t *image;
1575 
1576  for (i=0, image=gltextures ; i<numgltextures ; i++, image++)
1577  {
1578  if (!image->registration_sequence)
1579  continue; // free image_t slot
1580  // free it
1581  qglDeleteTextures (1, &image->texnum);
1582  memset (image, 0, sizeof(*image));
1583  }
1584 }

Referenced by R_Shutdown().

◆ GL_TexEnv()

void GL_TexEnv ( GLenum  mode)

Definition at line 126 of file gl_image.c.

127 {
128  static int lastmodes[2] = { -1, -1 };
129 
130  if ( mode != lastmodes[gl_state.currenttmu] )
131  {
132  qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode );
133  lastmodes[gl_state.currenttmu] = mode;
134  }
135 }

Referenced by DrawTextureChains(), GL_DrawParticles(), GL_EnableMultitexture(), GL_SetDefaultState(), R_DrawAliasModel(), R_DrawAlphaSurfaces(), R_DrawBrushModel(), R_DrawInlineBModel(), R_DrawSkyBox(), R_DrawSpriteModel(), R_DrawWorld(), and R_RenderBrushPoly().

◆ GL_TextureAlphaMode()

void GL_TextureAlphaMode ( char *  string)

Definition at line 255 of file gl_image.c.

256 {
257  int i;
258 
259  for (i=0 ; i< NUM_GL_ALPHA_MODES ; i++)
260  {
261  if ( !Q_stricmp( gl_alpha_modes[i].name, string ) )
262  break;
263  }
264 
265  if (i == NUM_GL_ALPHA_MODES)
266  {
267  ri.Con_Printf (PRINT_ALL, "bad alpha texture mode name\n");
268  return;
269  }
270 
272 }

Referenced by GL_SetDefaultState(), and R_BeginFrame().

◆ GL_TextureMode()

void GL_TextureMode ( char *  string)

Definition at line 218 of file gl_image.c.

219 {
220  int i;
221  image_t *glt;
222 
223  for (i=0 ; i< NUM_GL_MODES ; i++)
224  {
225  if ( !Q_stricmp( modes[i].name, string ) )
226  break;
227  }
228 
229  if (i == NUM_GL_MODES)
230  {
231  ri.Con_Printf (PRINT_ALL, "bad filter name\n");
232  return;
233  }
234 
237 
238  // change all the existing mipmap texture objects
239  for (i=0, glt=gltextures ; i<numgltextures ; i++, glt++)
240  {
241  if (glt->type != it_pic && glt->type != it_sky )
242  {
243  GL_Bind (glt->texnum);
244  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
245  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
246  }
247  }
248 }

Referenced by GL_SetDefaultState(), and R_BeginFrame().

◆ GL_TextureSolidMode()

void GL_TextureSolidMode ( char *  string)

Definition at line 279 of file gl_image.c.

280 {
281  int i;
282 
283  for (i=0 ; i< NUM_GL_SOLID_MODES ; i++)
284  {
285  if ( !Q_stricmp( gl_solid_modes[i].name, string ) )
286  break;
287  }
288 
289  if (i == NUM_GL_SOLID_MODES)
290  {
291  ri.Con_Printf (PRINT_ALL, "bad solid texture mode name\n");
292  return;
293  }
294 
296 }

Referenced by GL_SetDefaultState(), and R_BeginFrame().

◆ GL_Upload32()

qboolean GL_Upload32 ( unsigned *  data,
int  width,
int  height,
qboolean  mipmap 
)

Definition at line 968 of file gl_image.c.

969 {
970  int samples;
971  unsigned scaled[256*256];
972  unsigned char paletted_texture[256*256];
973  int scaled_width, scaled_height;
974  int i, c;
975  byte *scan;
976  int comp;
977 
978  uploaded_paletted = false;
979 
980  for (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)
981  ;
982  if (gl_round_down->value && scaled_width > width && mipmap)
983  scaled_width >>= 1;
984  for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)
985  ;
986  if (gl_round_down->value && scaled_height > height && mipmap)
987  scaled_height >>= 1;
988 
989  // let people sample down the world textures for speed
990  if (mipmap)
991  {
992  scaled_width >>= (int)gl_picmip->value;
993  scaled_height >>= (int)gl_picmip->value;
994  }
995 
996  // don't ever bother with >256 textures
997  if (scaled_width > 256)
998  scaled_width = 256;
999  if (scaled_height > 256)
1000  scaled_height = 256;
1001 
1002  if (scaled_width < 1)
1003  scaled_width = 1;
1004  if (scaled_height < 1)
1005  scaled_height = 1;
1006 
1007  upload_width = scaled_width;
1008  upload_height = scaled_height;
1009 
1010  if (scaled_width * scaled_height > sizeof(scaled)/4)
1011  ri.Sys_Error (ERR_DROP, "GL_Upload32: too big");
1012 
1013  // scan the texture for any non-255 alpha
1014  c = width*height;
1015  scan = ((byte *)data) + 3;
1016  samples = gl_solid_format;
1017  for (i=0 ; i<c ; i++, scan += 4)
1018  {
1019  if ( *scan != 255 )
1020  {
1021  samples = gl_alpha_format;
1022  break;
1023  }
1024  }
1025 
1026  if (samples == gl_solid_format)
1027  comp = gl_tex_solid_format;
1028  else if (samples == gl_alpha_format)
1029  comp = gl_tex_alpha_format;
1030  else {
1032  "Unknown number of texture components %i\n",
1033  samples);
1034  comp = samples;
1035  }
1036 
1037 #if 0
1038  if (mipmap)
1039  gluBuild2DMipmaps (GL_TEXTURE_2D, samples, width, height, GL_RGBA, GL_UNSIGNED_BYTE, trans);
1040  else if (scaled_width == width && scaled_height == height)
1041  qglTexImage2D (GL_TEXTURE_2D, 0, comp, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans);
1042  else
1043  {
1044  gluScaleImage (GL_RGBA, width, height, GL_UNSIGNED_BYTE, trans,
1045  scaled_width, scaled_height, GL_UNSIGNED_BYTE, scaled);
1046  qglTexImage2D (GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled);
1047  }
1048 #else
1049 
1050  if (scaled_width == width && scaled_height == height)
1051  {
1052  if (!mipmap)
1053  {
1054  if ( qglColorTableEXT && gl_ext_palettedtexture->value && samples == gl_solid_format )
1055  {
1056  uploaded_paletted = true;
1057  GL_BuildPalettedTexture( paletted_texture, ( unsigned char * ) data, scaled_width, scaled_height );
1058  qglTexImage2D( GL_TEXTURE_2D,
1059  0,
1061  scaled_width,
1062  scaled_height,
1063  0,
1064  GL_COLOR_INDEX,
1065  GL_UNSIGNED_BYTE,
1066  paletted_texture );
1067  }
1068  else
1069  {
1070  qglTexImage2D (GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
1071  }
1072  goto done;
1073  }
1074  memcpy (scaled, data, width*height*4);
1075  }
1076  else
1077  GL_ResampleTexture (data, width, height, scaled, scaled_width, scaled_height);
1078 
1079  GL_LightScaleTexture (scaled, scaled_width, scaled_height, !mipmap );
1080 
1081  if ( qglColorTableEXT && gl_ext_palettedtexture->value && ( samples == gl_solid_format ) )
1082  {
1083  uploaded_paletted = true;
1084  GL_BuildPalettedTexture( paletted_texture, ( unsigned char * ) scaled, scaled_width, scaled_height );
1085  qglTexImage2D( GL_TEXTURE_2D,
1086  0,
1088  scaled_width,
1089  scaled_height,
1090  0,
1091  GL_COLOR_INDEX,
1092  GL_UNSIGNED_BYTE,
1093  paletted_texture );
1094  }
1095  else
1096  {
1097  qglTexImage2D( GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled );
1098  }
1099 
1100  if (mipmap)
1101  {
1102  int miplevel;
1103 
1104  miplevel = 0;
1105  while (scaled_width > 1 || scaled_height > 1)
1106  {
1107  GL_MipMap ((byte *)scaled, scaled_width, scaled_height);
1108  scaled_width >>= 1;
1109  scaled_height >>= 1;
1110  if (scaled_width < 1)
1111  scaled_width = 1;
1112  if (scaled_height < 1)
1113  scaled_height = 1;
1114  miplevel++;
1115  if ( qglColorTableEXT && gl_ext_palettedtexture->value && samples == gl_solid_format )
1116  {
1117  uploaded_paletted = true;
1118  GL_BuildPalettedTexture( paletted_texture, ( unsigned char * ) scaled, scaled_width, scaled_height );
1119  qglTexImage2D( GL_TEXTURE_2D,
1120  miplevel,
1122  scaled_width,
1123  scaled_height,
1124  0,
1125  GL_COLOR_INDEX,
1126  GL_UNSIGNED_BYTE,
1127  paletted_texture );
1128  }
1129  else
1130  {
1131  qglTexImage2D (GL_TEXTURE_2D, miplevel, comp, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled);
1132  }
1133  }
1134  }
1135 done: ;
1136 #endif
1137 
1138 
1139  if (mipmap)
1140  {
1141  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
1142  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
1143  }
1144  else
1145  {
1146  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
1147  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
1148  }
1149 
1150  return (samples == gl_alpha_format);
1151 }

Referenced by GL_LoadPic(), and GL_Upload8().

◆ GL_Upload8()

qboolean GL_Upload8 ( byte data,
int  width,
int  height,
qboolean  mipmap,
qboolean  is_sky 
)

Definition at line 1177 of file gl_image.c.

1178 {
1179  unsigned trans[512*256];
1180  int i, s;
1181  int p;
1182 
1183  s = width*height;
1184 
1185  if (s > sizeof(trans)/4)
1186  ri.Sys_Error (ERR_DROP, "GL_Upload8: too large");
1187 
1188  if ( qglColorTableEXT &&
1190  is_sky )
1191  {
1192  qglTexImage2D( GL_TEXTURE_2D,
1193  0,
1195  width,
1196  height,
1197  0,
1198  GL_COLOR_INDEX,
1199  GL_UNSIGNED_BYTE,
1200  data );
1201 
1202  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
1203  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
1204  }
1205  else
1206  {
1207  for (i=0 ; i<s ; i++)
1208  {
1209  p = data[i];
1210  trans[i] = d_8to24table[p];
1211 
1212  if (p == 255)
1213  { // transparent, so scan around for another color
1214  // to avoid alpha fringes
1215  // FIXME: do a full flood fill so mips work...
1216  if (i > width && data[i-width] != 255)
1217  p = data[i-width];
1218  else if (i < s-width && data[i+width] != 255)
1219  p = data[i+width];
1220  else if (i > 0 && data[i-1] != 255)
1221  p = data[i-1];
1222  else if (i < s-1 && data[i+1] != 255)
1223  p = data[i+1];
1224  else
1225  p = 0;
1226  // copy rgb components
1227  ((byte *)&trans[i])[0] = ((byte *)&d_8to24table[p])[0];
1228  ((byte *)&trans[i])[1] = ((byte *)&d_8to24table[p])[1];
1229  ((byte *)&trans[i])[2] = ((byte *)&d_8to24table[p])[2];
1230  }
1231  }
1232 
1233  return GL_Upload32 (trans, width, height, mipmap);
1234  }
1235 
1236  return true;
1237 }

Referenced by GL_LoadPic(), and Scrap_Upload().

◆ LoadPCX()

void LoadPCX ( char *  filename,
byte **  pic,
byte **  palette,
int width,
int height 
)

Definition at line 433 of file gl_image.c.

434 {
435  byte *raw;
436  pcx_t *pcx;
437  int x, y;
438  int len;
439  int dataByte, runLength;
440  byte *out, *pix;
441 
442  *pic = NULL;
443  *palette = NULL;
444 
445  //
446  // load the file
447  //
448  len = ri.FS_LoadFile (filename, (void **)&raw);
449  if (!raw)
450  {
451  ri.Con_Printf (PRINT_DEVELOPER, "Bad pcx file %s\n", filename);
452  return;
453  }
454 
455  //
456  // parse the PCX file
457  //
458  pcx = (pcx_t *)raw;
459 
460  pcx->xmin = LittleShort(pcx->xmin);
461  pcx->ymin = LittleShort(pcx->ymin);
462  pcx->xmax = LittleShort(pcx->xmax);
463  pcx->ymax = LittleShort(pcx->ymax);
464  pcx->hres = LittleShort(pcx->hres);
465  pcx->vres = LittleShort(pcx->vres);
468 
469  raw = &pcx->data;
470 
471  if (pcx->manufacturer != 0x0a
472  || pcx->version != 5
473  || pcx->encoding != 1
474  || pcx->bits_per_pixel != 8
475  || pcx->xmax >= 640
476  || pcx->ymax >= 480)
477  {
478  ri.Con_Printf (PRINT_ALL, "Bad pcx file %s\n", filename);
479  return;
480  }
481 
482  out = malloc ( (pcx->ymax+1) * (pcx->xmax+1) );
483 
484  *pic = out;
485 
486  pix = out;
487 
488  if (palette)
489  {
490  *palette = malloc(768);
491  memcpy (*palette, (byte *)pcx + len - 768, 768);
492  }
493 
494  if (width)
495  *width = pcx->xmax+1;
496  if (height)
497  *height = pcx->ymax+1;
498 
499  for (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1)
500  {
501  for (x=0 ; x<=pcx->xmax ; )
502  {
503  dataByte = *raw++;
504 
505  if((dataByte & 0xC0) == 0xC0)
506  {
507  runLength = dataByte & 0x3F;
508  dataByte = *raw++;
509  }
510  else
511  runLength = 1;
512 
513  while(runLength-- > 0)
514  pix[x++] = dataByte;
515  }
516 
517  }
518 
519  if ( raw - (byte *)pcx > len)
520  {
521  ri.Con_Printf (PRINT_DEVELOPER, "PCX file %s was malformed", filename);
522  free (*pic);
523  *pic = NULL;
524  }
525 
526  ri.FS_FreeFile (pcx);
527 }

Referenced by Draw_GetPalette(), and GL_FindImage().

◆ LoadTGA()

void LoadTGA ( char *  name,
byte **  pic,
int width,
int height 
)

Definition at line 551 of file gl_image.c.

552 {
553  int columns, rows, numPixels;
554  byte *pixbuf;
555  int row, column;
556  byte *buf_p;
557  byte *buffer;
558  int length;
559  TargaHeader targa_header;
560  byte *targa_rgba;
561  byte tmp[2];
562 
563  *pic = NULL;
564 
565  //
566  // load the file
567  //
568  length = ri.FS_LoadFile (name, (void **)&buffer);
569  if (!buffer)
570  {
571  ri.Con_Printf (PRINT_DEVELOPER, "Bad tga file %s\n", name);
572  return;
573  }
574 
575  buf_p = buffer;
576 
577  targa_header.id_length = *buf_p++;
578  targa_header.colormap_type = *buf_p++;
579  targa_header.image_type = *buf_p++;
580 
581  tmp[0] = buf_p[0];
582  tmp[1] = buf_p[1];
583  targa_header.colormap_index = LittleShort ( *((short *)tmp) );
584  buf_p+=2;
585  tmp[0] = buf_p[0];
586  tmp[1] = buf_p[1];
587  targa_header.colormap_length = LittleShort ( *((short *)tmp) );
588  buf_p+=2;
589  targa_header.colormap_size = *buf_p++;
590  targa_header.x_origin = LittleShort ( *((short *)buf_p) );
591  buf_p+=2;
592  targa_header.y_origin = LittleShort ( *((short *)buf_p) );
593  buf_p+=2;
594  targa_header.width = LittleShort ( *((short *)buf_p) );
595  buf_p+=2;
596  targa_header.height = LittleShort ( *((short *)buf_p) );
597  buf_p+=2;
598  targa_header.pixel_size = *buf_p++;
599  targa_header.attributes = *buf_p++;
600 
601  if (targa_header.image_type!=2
602  && targa_header.image_type!=10)
603  ri.Sys_Error (ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n");
604 
605  if (targa_header.colormap_type !=0
606  || (targa_header.pixel_size!=32 && targa_header.pixel_size!=24))
607  ri.Sys_Error (ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n");
608 
609  columns = targa_header.width;
610  rows = targa_header.height;
611  numPixels = columns * rows;
612 
613  if (width)
614  *width = columns;
615  if (height)
616  *height = rows;
617 
618  targa_rgba = malloc (numPixels*4);
619  *pic = targa_rgba;
620 
621  if (targa_header.id_length != 0)
622  buf_p += targa_header.id_length; // skip TARGA image comment
623 
624  if (targa_header.image_type==2) { // Uncompressed, RGB images
625  for(row=rows-1; row>=0; row--) {
626  pixbuf = targa_rgba + row*columns*4;
627  for(column=0; column<columns; column++) {
628  unsigned char red,green,blue,alphabyte;
629  switch (targa_header.pixel_size) {
630  case 24:
631 
632  blue = *buf_p++;
633  green = *buf_p++;
634  red = *buf_p++;
635  *pixbuf++ = red;
636  *pixbuf++ = green;
637  *pixbuf++ = blue;
638  *pixbuf++ = 255;
639  break;
640  case 32:
641  blue = *buf_p++;
642  green = *buf_p++;
643  red = *buf_p++;
644  alphabyte = *buf_p++;
645  *pixbuf++ = red;
646  *pixbuf++ = green;
647  *pixbuf++ = blue;
648  *pixbuf++ = alphabyte;
649  break;
650  }
651  }
652  }
653  }
654  else if (targa_header.image_type==10) { // Runlength encoded RGB images
655  unsigned char red,green,blue,alphabyte,packetHeader,packetSize,j;
656  for(row=rows-1; row>=0; row--) {
657  pixbuf = targa_rgba + row*columns*4;
658  for(column=0; column<columns; ) {
659  packetHeader= *buf_p++;
660  packetSize = 1 + (packetHeader & 0x7f);
661  if (packetHeader & 0x80) { // run-length packet
662  switch (targa_header.pixel_size) {
663  case 24:
664  blue = *buf_p++;
665  green = *buf_p++;
666  red = *buf_p++;
667  alphabyte = 255;
668  break;
669  case 32:
670  blue = *buf_p++;
671  green = *buf_p++;
672  red = *buf_p++;
673  alphabyte = *buf_p++;
674  break;
675  }
676 
677  for(j=0;j<packetSize;j++) {
678  *pixbuf++=red;
679  *pixbuf++=green;
680  *pixbuf++=blue;
681  *pixbuf++=alphabyte;
682  column++;
683  if (column==columns) { // run spans across rows
684  column=0;
685  if (row>0)
686  row--;
687  else
688  goto breakOut;
689  pixbuf = targa_rgba + row*columns*4;
690  }
691  }
692  }
693  else { // non run-length packet
694  for(j=0;j<packetSize;j++) {
695  switch (targa_header.pixel_size) {
696  case 24:
697  blue = *buf_p++;
698  green = *buf_p++;
699  red = *buf_p++;
700  *pixbuf++ = red;
701  *pixbuf++ = green;
702  *pixbuf++ = blue;
703  *pixbuf++ = 255;
704  break;
705  case 32:
706  blue = *buf_p++;
707  green = *buf_p++;
708  red = *buf_p++;
709  alphabyte = *buf_p++;
710  *pixbuf++ = red;
711  *pixbuf++ = green;
712  *pixbuf++ = blue;
713  *pixbuf++ = alphabyte;
714  break;
715  }
716  column++;
717  if (column==columns) { // pixel packet run spans across rows
718  column=0;
719  if (row>0)
720  row--;
721  else
722  goto breakOut;
723  pixbuf = targa_rgba + row*columns*4;
724  }
725  }
726  }
727  }
728  breakOut:;
729  }
730  }
731 
733 }

Referenced by GL_FindImage().

◆ R_FloodFillSkin()

void R_FloodFillSkin ( byte skin,
int  skinwidth,
int  skinheight 
)

Definition at line 773 of file gl_image.c.

774 {
775  byte fillcolor = *skin; // assume this is the pixel to fill
777  int inpt = 0, outpt = 0;
778  int filledcolor = -1;
779  int i;
780 
781  if (filledcolor == -1)
782  {
783  filledcolor = 0;
784  // attempt to find opaque black
785  for (i = 0; i < 256; ++i)
786  if (d_8to24table[i] == (255 << 0)) // alpha 1.0
787  {
788  filledcolor = i;
789  break;
790  }
791  }
792 
793  // can't fill to filled color or to transparent color (used as visited marker)
794  if ((fillcolor == filledcolor) || (fillcolor == 255))
795  {
796  //printf( "not filling skin from %d to %d\n", fillcolor, filledcolor );
797  return;
798  }
799 
800  fifo[inpt].x = 0, fifo[inpt].y = 0;
801  inpt = (inpt + 1) & FLOODFILL_FIFO_MASK;
802 
803  while (outpt != inpt)
804  {
805  int x = fifo[outpt].x, y = fifo[outpt].y;
806  int fdc = filledcolor;
807  byte *pos = &skin[x + skinwidth * y];
808 
809  outpt = (outpt + 1) & FLOODFILL_FIFO_MASK;
810 
811  if (x > 0) FLOODFILL_STEP( -1, -1, 0 );
812  if (x < skinwidth - 1) FLOODFILL_STEP( 1, 1, 0 );
813  if (y > 0) FLOODFILL_STEP( -skinwidth, 0, -1 );
814  if (y < skinheight - 1) FLOODFILL_STEP( skinwidth, 0, 1 );
815  skin[x + skinwidth * y] = fdc;
816  }
817 }

Referenced by GL_LoadPic().

◆ R_RegisterSkin()

struct image_s* R_RegisterSkin ( char *  name)

Definition at line 1428 of file gl_image.c.

1429 {
1430  return GL_FindImage (name, it_skin);
1431 }

◆ Scrap_AllocBlock()

int Scrap_AllocBlock ( int  w,
int  h,
int x,
int y 
)

Definition at line 368 of file gl_image.c.

369 {
370  int i, j;
371  int best, best2;
372  int texnum;
373 
374  for (texnum=0 ; texnum<MAX_SCRAPS ; texnum++)
375  {
376  best = BLOCK_HEIGHT;
377 
378  for (i=0 ; i<BLOCK_WIDTH-w ; i++)
379  {
380  best2 = 0;
381 
382  for (j=0 ; j<w ; j++)
383  {
384  if (scrap_allocated[texnum][i+j] >= best)
385  break;
386  if (scrap_allocated[texnum][i+j] > best2)
387  best2 = scrap_allocated[texnum][i+j];
388  }
389  if (j == w)
390  { // this is a valid spot
391  *x = i;
392  *y = best = best2;
393  }
394  }
395 
396  if (best + h > BLOCK_HEIGHT)
397  continue;
398 
399  for (i=0 ; i<w ; i++)
400  scrap_allocated[texnum][*x + i] = best + h;
401 
402  return texnum;
403  }
404 
405  return -1;
406 // Sys_Error ("Scrap_AllocBlock: full");
407 }

Referenced by GL_LoadPic().

◆ Scrap_Upload()

void Scrap_Upload ( void  )

Definition at line 411 of file gl_image.c.

412 {
413  scrap_uploads++;
415  GL_Upload8 (scrap_texels[0], BLOCK_WIDTH, BLOCK_HEIGHT, false, false );
416  scrap_dirty = false;
417 }

Referenced by Draw_Pic(), and Draw_StretchPic().

Variable Documentation

◆ base_textureid

int base_textureid

Definition at line 26 of file gl_image.c.

◆ d_8to24table

unsigned d_8to24table[256]

Definition at line 33 of file gl_image.c.

Referenced by Draw_GetPalette(), GL_Upload8(), and R_FloodFillSkin().

◆ gammatable

unsigned char gammatable[256]
static

Definition at line 29 of file gl_image.c.

Referenced by GL_InitImages(), and GL_LightScaleTexture().

◆ gl_alpha_format

int gl_alpha_format = 4

Definition at line 40 of file gl_image.c.

Referenced by GL_Upload32().

◆ gl_alpha_modes

gltmode_t gl_alpha_modes[]
Initial value:
= {
{"default", 4},
{"GL_RGBA", GL_RGBA},
{"GL_RGBA8", GL_RGBA8},
{"GL_RGB5_A1", GL_RGB5_A1},
{"GL_RGBA4", GL_RGBA4},
{"GL_RGBA2", GL_RGBA2},
}

Definition at line 188 of file gl_image.c.

Referenced by GL_TextureAlphaMode().

◆ gl_filter_max

int gl_filter_max = GL_LINEAR

Definition at line 46 of file gl_image.c.

Referenced by GL_SetDefaultState(), GL_TextureMode(), GL_Upload32(), and GL_Upload8().

◆ gl_filter_min

int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST

Definition at line 45 of file gl_image.c.

Referenced by GL_SetDefaultState(), GL_TextureMode(), and GL_Upload32().

◆ gl_solid_format

int gl_solid_format = 3

Definition at line 39 of file gl_image.c.

Referenced by GL_Upload32().

◆ gl_solid_modes

gltmode_t gl_solid_modes[]
Initial value:
= {
{"default", 3},
{"GL_RGB", GL_RGB},
{"GL_RGB8", GL_RGB8},
{"GL_RGB5", GL_RGB5},
{"GL_RGB4", GL_RGB4},
{"GL_R3_G3_B2", GL_R3_G3_B2},
}

Definition at line 199 of file gl_image.c.

Referenced by GL_TextureSolidMode().

◆ gl_tex_alpha_format

int gl_tex_alpha_format = 4

Definition at line 43 of file gl_image.c.

Referenced by GL_BeginBuildingLightmaps(), GL_TextureAlphaMode(), and GL_Upload32().

◆ gl_tex_solid_format

int gl_tex_solid_format = 3

◆ gltextures

◆ intensity

cvar_t* intensity

◆ intensitytable

byte intensitytable[256]
static

Definition at line 28 of file gl_image.c.

Referenced by GL_InitImages(), and GL_LightScaleTexture().

◆ modes

glmode_t modes[]
Initial value:
= {
{"GL_NEAREST", GL_NEAREST, GL_NEAREST},
{"GL_LINEAR", GL_LINEAR, GL_LINEAR},
{"GL_NEAREST_MIPMAP_NEAREST", GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST},
{"GL_LINEAR_MIPMAP_NEAREST", GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR},
{"GL_NEAREST_MIPMAP_LINEAR", GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST},
{"GL_LINEAR_MIPMAP_LINEAR", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR}
}

Definition at line 171 of file gl_image.c.

Referenced by GL_TextureMode().

◆ numgltextures

◆ scrap_allocated

int scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH]

Definition at line 363 of file gl_image.c.

Referenced by Scrap_AllocBlock().

◆ scrap_dirty

qboolean scrap_dirty

Definition at line 365 of file gl_image.c.

Referenced by Draw_Pic(), Draw_StretchPic(), GL_LoadPic(), and Scrap_Upload().

◆ scrap_texels

Definition at line 364 of file gl_image.c.

Referenced by GL_LoadPic(), and Scrap_Upload().

◆ scrap_uploads

int scrap_uploads

Definition at line 409 of file gl_image.c.

Referenced by Scrap_Upload().

◆ upload_height

int upload_height

Definition at line 965 of file gl_image.c.

Referenced by GL_LoadPic(), and GL_Upload32().

◆ upload_width

int upload_width

Definition at line 965 of file gl_image.c.

Referenced by GL_LoadPic(), and GL_Upload32().

◆ uploaded_paletted

qboolean uploaded_paletted

Definition at line 966 of file gl_image.c.

Referenced by GL_LoadPic(), and GL_Upload32().

GL_RENDERER_VOODOO
#define GL_RENDERER_VOODOO
Definition: gl_local.h:356
MAX_SCRAPS
#define MAX_SCRAPS
Definition: gl_image.c:359
FLOODFILL_FIFO_MASK
#define FLOODFILL_FIFO_MASK
Definition: gl_image.c:760
it_sprite
@ it_sprite
Definition: r_local.h:65
numgltextures
int numgltextures
Definition: gl_image.c:25
LoadTGA
void LoadTGA(char *name, byte **pic, int *width, int *height)
Definition: gl_image.c:551
height
GLsizei height
Definition: qgl_win.c:69
GL_COLOR_INDEX8_EXT
#define GL_COLOR_INDEX8_EXT
Definition: gl_local.h:34
scrap_uploads
int scrap_uploads
Definition: gl_image.c:409
LittleShort
short LittleShort(short l)
Definition: q_shared.c:946
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
green
GLfloat green
Definition: qgl_win.c:74
image_s::th
float th
Definition: gl_local.h:96
_TargaHeader::y_origin
unsigned short y_origin
Definition: r_image.c:194
r_notexture
image_t * r_notexture
Definition: gl_rmain.c:44
scrap_texels
byte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH *BLOCK_HEIGHT]
Definition: gl_image.c:364
GL_SHARED_TEXTURE_PALETTE_EXT
#define GL_SHARED_TEXTURE_PALETTE_EXT
Definition: qgl.h:476
scrap_dirty
qboolean scrap_dirty
Definition: gl_image.c:365
gl_state
glstate_t gl_state
Definition: gl_rmain.c:42
skinwidth
int skinwidth
Definition: r_polyse.c:127
ri
refimport_t ri
Definition: r_main.c:25
pcx_t
Definition: qfiles.h:60
glstate_t::currenttextures
int currenttextures[2]
Definition: gl_local.h:418
PRINT_DEVELOPER
#define PRINT_DEVELOPER
Definition: qcommon.h:752
d_8to24table
unsigned d_8to24table[256]
Definition: gl_image.c:33
miptex_s
Definition: qfiles.h:198
GL_LoadWal
image_t * GL_LoadWal(char *name)
Definition: gl_image.c:1332
v
GLdouble v
Definition: qgl_win.c:143
it_wall
@ it_wall
Definition: r_local.h:66
gl_texture1
int gl_texture1
Definition: gl_rmain.c:35
_TargaHeader::x_origin
unsigned short x_origin
Definition: r_image.c:194
_TargaHeader::pixel_size
unsigned char pixel_size
Definition: r_image.c:195
glstate_t::currenttmu
int currenttmu
Definition: gl_local.h:419
refimport_t::FS_LoadFile
int(* FS_LoadFile)(char *name, void **buf)
Definition: ref.h:209
pix
static int pix
Definition: r_part.c:472
refimport_t::Cvar_Get
cvar_t *(* Cvar_Get)(char *name, char *value, int flags)
Definition: ref.h:216
pcx_t::version
char version
Definition: qfiles.h:63
pcx_t::data
unsigned char data
Definition: qfiles.h:74
x
GLint GLenum GLint x
Definition: qgl_win.c:116
i
int i
Definition: q_shared.c:305
gl_solid_format
int gl_solid_format
Definition: gl_image.c:39
gl_alpha_modes
gltmode_t gl_alpha_modes[]
Definition: gl_image.c:188
gammatable
static unsigned char gammatable[256]
Definition: gl_image.c:29
NUM_GL_ALPHA_MODES
#define NUM_GL_ALPHA_MODES
Definition: gl_image.c:197
buffer
GLenum GLfloat * buffer
Definition: qgl_win.c:151
upload_width
int upload_width
Definition: gl_image.c:965
refimport_t::Cvar_Set
cvar_t *(* Cvar_Set)(char *name, char *value)
Definition: ref.h:217
GL_Upload32
qboolean GL_Upload32(unsigned *data, int width, int height, qboolean mipmap)
Definition: gl_image.c:968
floodfill_t::x
short x
Definition: gl_image.c:755
gl_texture0
int gl_texture0
Definition: gl_rmain.c:35
_TargaHeader::image_type
unsigned char image_type
Definition: r_image.c:191
width
GLint GLsizei width
Definition: qgl_win.c:115
gl_round_down
cvar_t * gl_round_down
Definition: gl_rmain.c:120
scrap_allocated
int scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH]
Definition: gl_image.c:363
pcx_t::hres
unsigned short hres
Definition: qfiles.h:67
gl_nobind
cvar_t * gl_nobind
Definition: gl_rmain.c:119
image_s::registration_sequence
int registration_sequence
Definition: r_local.h:77
type
GLenum type
Definition: qgl_win.c:72
uploaded_paletted
qboolean uploaded_paletted
Definition: gl_image.c:966
_TargaHeader::colormap_size
unsigned char colormap_size
Definition: r_image.c:193
NUM_GL_SOLID_MODES
#define NUM_GL_SOLID_MODES
Definition: gl_image.c:211
glmode_t::minimize
int minimize
Definition: gl_image.c:168
_TargaHeader::colormap_index
unsigned short colormap_index
Definition: r_image.c:192
intensity
cvar_t * intensity
Definition: gl_image.c:31
refimport_t::FS_FreeFile
void(* FS_FreeFile)(void *buf)
Definition: ref.h:210
j
GLint j
Definition: qgl_win.c:150
gl_solid_modes
gltmode_t gl_solid_modes[]
Definition: gl_image.c:199
R_FloodFillSkin
void R_FloodFillSkin(byte *skin, int skinwidth, int skinheight)
Definition: gl_image.c:773
gl_filter_min
int gl_filter_min
Definition: gl_image.c:45
gl_tex_alpha_format
int gl_tex_alpha_format
Definition: gl_image.c:43
GL_MipMap
void GL_MipMap(byte *in, int width, int height)
Definition: gl_image.c:918
gltextures
image_t gltextures[MAX_GLTEXTURES]
Definition: gl_image.c:24
refimport_t::Con_Printf
void(* Con_Printf)(int print_level, char *str,...)
Definition: ref.h:202
GL_FindImage
image_t * GL_FindImage(char *name, imagetype_t type)
Definition: gl_image.c:1363
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:751
pcx_t::ymin
unsigned short ymin
Definition: qfiles.h:66
TEXNUM_IMAGES
#define TEXNUM_IMAGES
Definition: gl_local.h:105
image_s::scrap
qboolean scrap
Definition: gl_local.h:97
skin
cvar_t * skin
Definition: cl_main.c:80
miplevel
static int miplevel
Definition: r_edge.c:77
it_pic
@ it_pic
Definition: r_local.h:67
gl_alpha_format
int gl_alpha_format
Definition: gl_image.c:40
r
GLdouble GLdouble r
Definition: qgl_win.c:336
gltmode_t::mode
int mode
Definition: gl_image.c:185
LittleLong
int LittleLong(int l)
Definition: q_shared.c:948
image_s::height
int height
Definition: r_local.h:75
_TargaHeader::colormap_length
unsigned short colormap_length
Definition: r_image.c:192
intensitytable
static byte intensitytable[256]
Definition: gl_image.c:28
image_s::texnum
int texnum
Definition: gl_local.h:95
refimport_t::Sys_Error
void(* Sys_Error)(int err_level, char *str,...)
Definition: ref.h:194
GL_Bind
void GL_Bind(int texnum)
Definition: gl_image.c:137
gl_picmip
static cvar_t * gl_picmip
Definition: vid_menu.c:39
glmode_t::maximize
int maximize
Definition: gl_image.c:168
_TargaHeader::attributes
unsigned char attributes
Definition: r_image.c:195
pcx_t::ymax
unsigned short ymax
Definition: qfiles.h:66
cvar_s::value
float value
Definition: q_shared.h:331
r_particletexture
image_t * r_particletexture
Definition: gl_rmain.c:45
GL_Upload8
qboolean GL_Upload8(byte *data, int width, int height, qboolean mipmap, qboolean is_sky)
Definition: gl_image.c:1177
FLOODFILL_STEP
#define FLOODFILL_STEP(off, dx, dy)
Definition: gl_image.c:762
MAX_GLTEXTURES
#define MAX_GLTEXTURES
Definition: gl_local.h:107
floodfill_t
Definition: gl_image.c:753
image_s::type
imagetype_t type
Definition: r_local.h:74
pcx_t::encoding
char encoding
Definition: qfiles.h:64
NULL
#define NULL
Definition: q_shared.h:67
GL_ResampleTexture
void GL_ResampleTexture(unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight)
Definition: gl_image.c:827
glstate_t::inverse_intensity
float inverse_intensity
Definition: gl_local.h:409
image_s::width
int width
Definition: r_local.h:75
modes
glmode_t modes[]
Definition: gl_image.c:171
image_s::tl
float tl
Definition: gl_local.h:96
pcx_t::palette_type
unsigned short palette_type
Definition: qfiles.h:72
upload_height
int upload_height
Definition: gl_image.c:965
image_s::name
char name[MAX_QPATH]
Definition: r_local.h:73
ERR_DROP
#define ERR_DROP
Definition: qcommon.h:744
Q_stricmp
int Q_stricmp(char *s1, char *s2)
Definition: q_shared.c:1180
it_skin
@ it_skin
Definition: r_local.h:64
gl_filter_max
int gl_filter_max
Definition: gl_image.c:46
pcx_t::bits_per_pixel
char bits_per_pixel
Definition: qfiles.h:65
name
cvar_t * name
Definition: cl_main.c:79
ERR_FATAL
#define ERR_FATAL
Definition: qcommon.h:743
pcx_t::xmin
unsigned short xmin
Definition: qfiles.h:66
glconfig_t::renderer
int renderer
Definition: gl_local.h:398
s
static fixed16_t s
Definition: r_scan.c:30
y
GLint y
Definition: qgl_win.c:115
image_s::paletted
qboolean paletted
Definition: gl_local.h:100
GL_RENDERER_VOODOO2
#define GL_RENDERER_VOODOO2
Definition: gl_local.h:357
FLOODFILL_FIFO_SIZE
#define FLOODFILL_FIFO_SIZE
Definition: gl_image.c:759
_TargaHeader
Definition: r_image.c:190
gl_tex_solid_format
int gl_tex_solid_format
Definition: gl_image.c:42
trans
static int trans[3]
Definition: r_polyse.c:928
image_s::upload_width
int upload_width
Definition: gl_local.h:92
image_s::sl
float sl
Definition: gl_local.h:96
vid_gamma
cvar_t * vid_gamma
Definition: vid_dll.c:43
gl_config
glconfig_t gl_config
Definition: gl_rmain.c:41
GL_TexEnv
void GL_TexEnv(GLenum mode)
Definition: gl_image.c:126
image_s::has_alpha
qboolean has_alpha
Definition: gl_local.h:98
blue
GLfloat GLfloat blue
Definition: qgl_win.c:74
gl_ext_palettedtexture
static cvar_t * gl_ext_palettedtexture
Definition: vid_menu.c:40
pcx_t::manufacturer
char manufacturer
Definition: qfiles.h:62
_TargaHeader::colormap_type
unsigned char colormap_type
Definition: r_image.c:191
_TargaHeader::width
unsigned short width
Definition: r_image.c:194
GL_LoadPic
image_t * GL_LoadPic(char *name, byte *pic, int width, int height, imagetype_t type, int bits)
Definition: gl_image.c:1247
_TargaHeader::id_length
unsigned char id_length
Definition: r_image.c:191
BLOCK_HEIGHT
#define BLOCK_HEIGHT
Definition: gl_image.c:361
pcx_t::vres
unsigned short vres
Definition: qfiles.h:67
_TargaHeader::height
unsigned short height
Definition: r_image.c:194
texture
GLuint texture
Definition: qgl_win.c:68
image_s::upload_height
int upload_height
Definition: gl_local.h:92
w
GLdouble GLdouble GLdouble w
Definition: qgl_win.c:291
registration_sequence
int registration_sequence
Definition: r_model.c:44
GL_BuildPalettedTexture
void GL_BuildPalettedTexture(unsigned char *paletted_texture, unsigned char *scaled, int scaled_width, int scaled_height)
Definition: gl_image.c:945
image_s
Definition: r_local.h:71
mode
GLenum mode
Definition: qgl_win.c:113
pcx_t::xmax
unsigned short xmax
Definition: qfiles.h:66
GL_SelectTexture
void GL_SelectTexture(GLenum texture)
Definition: gl_image.c:92
floodfill_t::y
short y
Definition: gl_image.c:755
Draw_GetPalette
int Draw_GetPalette(void)
Definition: gl_image.c:1471
Scrap_AllocBlock
int Scrap_AllocBlock(int w, int h, int *x, int *y)
Definition: gl_image.c:368
LoadPCX
void LoadPCX(char *filename, byte **pic, byte **palette, int *width, int *height)
Definition: gl_image.c:433
NUM_GL_MODES
#define NUM_GL_MODES
Definition: gl_image.c:180
draw_chars
image_t * draw_chars
Definition: r_draw.c:26
glstate_t::d_16to8table
unsigned char * d_16to8table
Definition: gl_local.h:414
TEXNUM_SCRAPS
#define TEXNUM_SCRAPS
Definition: gl_local.h:104
GL_LightScaleTexture
void GL_LightScaleTexture(unsigned *in, int inwidth, int inheight, qboolean only_gamma)
Definition: gl_image.c:877
BLOCK_WIDTH
#define BLOCK_WIDTH
Definition: gl_image.c:360
pcx_t::bytes_per_line
unsigned short bytes_per_line
Definition: qfiles.h:71
image_s::sh
float sh
Definition: gl_local.h:96
it_sky
@ it_sky
Definition: r_local.h:68