27cvar_t gl_max_size = {
CF_CLIENT |
CF_ARCHIVE,
"gl_max_size",
"2048",
"maximum allowed texture size, can be used to reduce video memory usage, limited by hardware capabilities (typically 2048, 4096, or 8192)"};
28cvar_t gl_max_lightmapsize = {
CF_CLIENT |
CF_ARCHIVE,
"gl_max_lightmapsize",
"512",
"maximum allowed texture size for lightmap textures, use larger values to improve rendering speed, as long as there is enough video memory available (setting it too high for the hardware will cause very bad performance)"};
29cvar_t gl_picmip = {
CF_CLIENT |
CF_ARCHIVE,
"gl_picmip",
"0",
"reduces resolution of textures by powers of 2, for example 1 will halve width/height, reducing texture memory usage by 75%"};
33cvar_t r_picmipsprites = {
CF_CLIENT |
CF_ARCHIVE,
"r_picmipsprites",
"1",
"make gl_picmip affect sprites too (saves some graphics memory in sprite heavy games) (setting this to 0 is a shorthand for gl_picmip_sprites -9999999)"};
37cvar_t gl_texturecompression = {
CF_CLIENT |
CF_ARCHIVE,
"gl_texturecompression",
"0",
"whether to compress textures, a value of 0 disables compression (even if the individual cvars are 1), 1 enables fast (low quality) compression at startup, 2 enables slow (high quality) compression at startup"};
63#define GLTEXF_IMPORTANTBITS (0)
65#define GLTEXF_DYNAMIC 0x00080000
67typedef struct textypeinfo_s
155typedef enum gltexturetype_e
165#ifdef GL_TEXTURE_WRAP_R
178typedef struct gltexture_s
195 int modified_mins[3], modified_maxs[3];
239#define TEXTUREPOOL_SENTINEL 0xC0DEDBAD
241typedef struct gltexturepool_s
305 Host_Error(
"R_GetTexTypeInfo: unknown texture format %i with flags %x", (
int)textype,
flags);
359 for (gltpointer = &glt->
pool->gltchain;*gltpointer && *gltpointer != glt;gltpointer = &(*gltpointer)->
chain);
360 if (*gltpointer == glt)
361 *gltpointer = glt->
chain;
406 if (rtexturepool ==
NULL)
408 if (*rtexturepool ==
NULL)
411 *rtexturepool =
NULL;
413 Host_Error(
"R_FreeTexturePool: pool already freed");
414 for (poolpointer = &
gltexturepoolchain;*poolpointer && *poolpointer != pool;poolpointer = &(*poolpointer)->
next);
415 if (*poolpointer == pool)
416 *poolpointer = pool->
next;
418 Host_Error(
"R_FreeTexturePool: pool not linked");
425typedef struct glmode_s
452 for (
i = 0;
i < 6;
i++)
460 Con_Print(
"current filter is unknown???\n");
464 for (
i = 0;
i < (
int)(
sizeof(
modes)/
sizeof(*modes));
i++)
511static void GL_Texture_CalcImageSize(
int texturetype,
int flags,
int miplevel,
int inwidth,
int inheight,
int indepth,
int *outwidth,
int *outheight,
int *outdepth,
int *outmiplevels)
513 int picmip = 0, maxsize = 0, width2 = 1, height2 = 1, depth2 = 1, miplevels = 1;
534 width2 =
min(inwidth >> picmip, maxsize);
535 height2 =
min(inheight >> picmip, maxsize);
536 depth2 =
min(indepth >> picmip, maxsize);
541 int extent =
max(width2,
max(height2, depth2));
547 *outwidth =
max(1, width2);
549 *outheight =
max(1, height2);
551 *outdepth =
max(1, depth2);
553 *outmiplevels = miplevels;
559 int width2, height2, depth2,
size;
563 size = width2 * height2 * depth2;
567 while (width2 > 1 || height2 > 1 || depth2 > 1)
575 size += width2 * height2 * depth2;
586 int pooltotal = 0, pooltotalt = 0, pooltotalp = 0, poolloaded = 0, poolloadedt = 0, poolloadedp = 0;
587 int sumtotal = 0, sumtotalt = 0, sumtotalp = 0, sumloaded = 0, sumloadedt = 0, sumloadedp = 0;
591 Con_Print(
"glsize input loaded mip alpha name\n");
605 pooltotalt += glsize;
610 poolloadedt += glsize;
614 Con_Printf(
"%c%4i%c%c%4i%c %-24s %s %s %s %s\n", isloaded ?
'[' :
' ', (glsize + 1023) / 1024, isloaded ?
']' :
' ', glt->
inputtexels ?
'[' :
' ', (glt->
inputdatasize + 1023) / 1024, glt->
inputtexels ?
']' :
' ', glt->
textype->
name, isloaded ?
"loaded" :
" ", (glt->
flags &
TEXF_MIPMAP) ?
"mip" :
" ", (glt->
flags &
TEXF_ALPHA) ?
"alpha" :
" ", glt->
identifier);
617 Con_Printf(
"texturepool %10p total: %i (%.3fMB, %.3fMB original), uploaded %i (%.3fMB, %.3fMB original), upload on demand %i (%.3fMB, %.3fMB original)\n", (
void *)pool, pooltotal, pooltotalt / 1048576.0, pooltotalp / 1048576.0, poolloaded, poolloadedt / 1048576.0, poolloadedp / 1048576.0, pooltotal - poolloaded, (pooltotalt - poolloadedt) / 1048576.0, (pooltotalp - poolloadedp) / 1048576.0);
618 sumtotal += pooltotal;
619 sumtotalt += pooltotalt;
620 sumtotalp += pooltotalp;
621 sumloaded += poolloaded;
622 sumloadedt += poolloadedt;
623 sumloadedp += poolloadedp;
626 Con_Printf(
"textures total: %i (%.3fMB, %.3fMB original), uploaded %i (%.3fMB, %.3fMB original), upload on demand %i (%.3fMB, %.3fMB original)\n", sumtotal, sumtotalt / 1048576.0, sumtotalp / 1048576.0, sumloaded, sumloadedt / 1048576.0, sumloadedp / 1048576.0, sumtotal - sumloaded, (sumtotalt - sumloadedt) / 1048576.0, (sumtotalp - sumloadedp) / 1048576.0);
686 for (
i = 0;
i < endindex;
i++)
705 for (
i = 0;
i < endindex;
i++)
722 Cmd_AddCommand(
CF_CLIENT,
"gl_texturemode", &
GL_TextureMode_f,
"set texture filtering mode (GL_NEAREST, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, etc); an additional argument 'force' forces the texture mode even in cases where it may not be appropriate");
755#ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT
756 static int old_aniso = 0;
757 static qbool first_time_aniso =
true;
776#ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT
792 if (first_time_aniso)
794 first_time_aniso =
false;
844#ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT
855#ifdef GL_TEXTURE_WRAP_R
931 Sys_Error(
"R_UploadPartialTexture \"%s\": partial update with NULL pixels", glt->
identifier);
934 Sys_Error(
"R_UploadPartialTexture \"%s\": partial update of type other than 2D", glt->
identifier);
937 Sys_Error(
"R_UploadPartialTexture \"%s\": partial update of paletted texture", glt->
identifier);
940 Sys_Error(
"R_UploadPartialTexture \"%s\": partial update not supported with MIPMAP or PICMIP flags", glt->
identifier);
943 Sys_Error(
"R_UploadPartialTexture \"%s\": partial update not supported with stretched or special textures", glt->
identifier);
968 GLint oldbindtexnum = 0;
969 const unsigned char *prevbuffer;
974 Sys_Error(
"R_UploadFullTexture \"%s\": stretch uploads allowed only on 2D textures\n", glt->
identifier);
983 if (prevbuffer ==
NULL)
1087 for (
i = 0;
i < 6;
i++)
1126static rtexture_t *
R_SetupTexture(
rtexturepool_t *rtexturepool,
const char *identifier,
int width,
int height,
int depth,
int sides,
int flags,
int miplevel,
textype_t textype,
int texturetype,
const unsigned char *
data,
const unsigned int *palette)
1132 unsigned char *temppixels =
NULL;
1142 size = numpixels * 4;
1146 const unsigned char *p;
1147 unsigned char *o = temppixels;
1148 for (
i = 0;
i < numpixels;
i++, o += 4)
1150 p = (
const unsigned char *)palette + 4*
data[
i];
1172 static int rgbaswapindices[4] = {2, 1, 0, 3};
1183 qbool convertsRGB =
false;
1196 if (convertsRGB &&
data)
1224 flags &= ~TEXF_ALPHA;
1229 if (((
unsigned char *)&palette[
data[
i]])[3] < 255)
1244 flags &= ~TEXF_ALPHA;
1283 Sys_Error(
"R_LoadTexture: unknown texture type");
1290 Con_Printf (
"R_LoadTexture: input size changed after alpha fallback\n");
1354 return R_SetupTexture(rtexturepool, identifier,
width,
height, 1, 1,
flags, miplevel, textype,
GLTEXTURETYPE_2D,
data, palette);
1359 return R_SetupTexture(rtexturepool, identifier,
width,
height,
depth, 1,
flags, miplevel, textype,
GLTEXTURETYPE_3D,
data, palette);
1364 return R_SetupTexture(rtexturepool, identifier,
width,
width, 1, 6,
flags, miplevel, textype,
GLTEXTURETYPE_CUBEMAP,
data, palette);
1369 return R_SetupTexture(rtexturepool, identifier,
width,
height, 1, 1,
TEXF_RENDERTARGET |
TEXF_CLAMP | (
filter ?
TEXF_FORCELINEAR :
TEXF_FORCENEAREST), -1, textype,
GLTEXTURETYPE_2D,
NULL,
NULL);
1439 int bytesperpixel = 0;
1440 int bytesperblock = 0;
1442 int dds_format_flags;
1451 const char *ddsfourcc;
1454 if (!strcmp(
gl_version,
"2.0.5885 WinXP Release"))
1456 if (!qglGetTexLevelParameteriv)
1464 default: ddsfourcc =
NULL;bytesperpixel = 4;
break;
1479 if (!bytesperblock && skipuncompressed)
1481 memset(mipinfo, 0,
sizeof(mipinfo));
1487 for (mip = 1;mip < 16;mip++)
1489 mipinfo[mip][0] = mipinfo[mip-1][0] > 1 ? mipinfo[mip-1][0] >> 1 : 1;
1490 mipinfo[mip][1] = mipinfo[mip-1][1] > 1 ? mipinfo[mip-1][1] >> 1 : 1;
1491 if (mipinfo[mip][0] == 1 && mipinfo[mip][1] == 1)
1499 for (mip = 0;mip < mipmaps;mip++)
1501 mipinfo[mip][2] = bytesperblock ? ((mipinfo[mip][0]+3)/4)*((mipinfo[mip][1]+3)/4)*bytesperblock : mipinfo[mip][0]*mipinfo[mip][1]*bytesperpixel;
1502 mipinfo[mip][3] = ddssize;
1503 ddssize += mipinfo[mip][2];
1512 dds_flags = 0x81007;
1513 dds_format_flags = 0x4;
1518 dds_format_flags = 0x40;
1522 dds_flags |= 0x20000;
1523 dds_caps1 |= 0x400008;
1526 dds_format_flags |= 0x1;
1527 memcpy(dds,
"DDS ", 4);
1541 memcpy(dds+84, ddsfourcc, 4);
1542 for (mip = 0;mip < mipmaps;mip++)
1551 dds[94] = dds[97] = dds[100] = dds[107] = 255;
1552 for (mip = 0;mip < mipmaps;mip++)
1560 return ret ? ddssize : -5;
1566#include "ktx10/include/ktx.h"
1571 int i,
size, dds_format_flags, dds_miplevels, dds_width, dds_height;
1574 int bytesperblock, bytesperpixel;
1579 int mip, mipwidth, mipheight, mipsize, mipsize_total;
1580 unsigned int c,
r,
g,
b;
1581 GLint oldbindtexnum = 0;
1582 unsigned char *mippixels;
1583 unsigned char *mippixels_start;
1584 unsigned char *ddspixels;
1587 unsigned int ddssize;
1588 qbool force_swdecode;
1594 KTX_dimensions sizes;
1604 Con_DPrintf(
"KTX texture format is only supported on the GLES2 renderpath\n");
1614 for (
i = 0;
i <= strsize - 4;
i++)
1615 vabuf[
i] = vabuf[
i + 4];
1619 ddssize = ddsfilesize;
1630 Con_DPrintf(
"KTX texture with alpha not supported yet, disabling\n");
1631 flags &= ~TEXF_ALPHA;
1638 KTX_error_code ktxerror;
1656 ktxerror = ktxLoadTextureM(dds, ddssize, &glt->
texnum, &
target, &sizes, &isMipmapped, &glerror,
1668 if (KTX_SUCCESS == ktxerror)
1671 flags &= ~TEXF_COMPRESS;
1685 flags &= ~TEXF_MIPMAP;
1712#ifdef GL_TEXTURE_MAX_LEVEL
1731 Con_DPrintf(
"KTX texture %s failed to load: %x\n", vabuf, ktxerror);
1738 ddssize = ddsfilesize;
1743 Log_Printf(
"ddstexturefailures.log",
"%s\n", filename);
1750 Con_Printf(
"^1%s: not a DDS image\n", filename);
1759 ddspixels = dds + 128;
1762 if(!(dds_format_flags & 0x1))
1763 flags &= ~TEXF_ALPHA;
1770 flags &= ~TEXF_COMPRESS;
1777 Con_Printf(
"^1%s: invalid BGRA DDS image\n", filename);
1784 if (ddspixels[
i] < 255)
1787 flags &= ~TEXF_ALPHA;
1790 else if (!memcmp(dds+84,
"DXT1", 4))
1803 Con_Printf(
"^1%s: invalid DXT1 DDS image\n", filename);
1811 for (
i = 0;
i <
size;
i += bytesperblock)
1812 if (ddspixels[
i+0] + ddspixels[
i+1] * 256 <= ddspixels[
i+2] + ddspixels[
i+3] * 256)
1815 unsigned int data = * (
unsigned int *) &(ddspixels[
i+4]);
1823 flags &= ~TEXF_ALPHA;
1829 flags &= ~TEXF_ALPHA;
1833 else if (!memcmp(dds+84,
"DXT3", 4) || !memcmp(dds+84,
"DXT2", 4))
1835 if(!memcmp(dds+84,
"DXT2", 4))
1839 Con_Printf(
"^1%s: expecting DXT3 image without premultiplied alpha, got DXT2 image with premultiplied alpha\n", filename);
1846 Con_Printf(
"^1%s: expecting DXT2 image without premultiplied alpha, got DXT3 image without premultiplied alpha\n", filename);
1856 Con_Printf(
"^1%s: invalid DXT3 DDS image\n", filename);
1861 else if (!memcmp(dds+84,
"DXT5", 4) || !memcmp(dds+84,
"DXT4", 4))
1863 if(!memcmp(dds+84,
"DXT4", 4))
1867 Con_Printf(
"^1%s: expecting DXT5 image without premultiplied alpha, got DXT4 image with premultiplied alpha\n", filename);
1874 Con_Printf(
"^1%s: expecting DXT4 image without premultiplied alpha, got DXT5 image without premultiplied alpha\n", filename);
1884 Con_Printf(
"^1%s: invalid DXT5 DDS image\n", filename);
1892 Con_Printf(
"^1%s: unrecognized/unsupported DDS format\n", filename);
1903 for (
i = 0;
i < (
int)ddssize;
i += bytesperblock)
1904 memcpy(&ddspixels[
i], &ddspixels[(
i<<1)+8], 8);
1908 force_swdecode =
false;
1914 force_swdecode =
true;
1924 force_swdecode =
true;
1939 Con_DPrintf(
"WARNING: fake software decoding of compressed texture %s degraded quality\n", filename);
1943 mippixels_start = ddspixels;
1944 mipwidth = dds_width;
1945 mipheight = dds_height;
1946 while(miplevel >= 1 && dds_miplevels >= 1)
1948 if (mipwidth <= 1 && mipheight <= 1)
1950 mipsize = bytesperblock ? ((mipwidth+3)/4)*((mipheight+3)/4)*bytesperblock : mipwidth*mipheight*bytesperpixel;
1951 mippixels_start += mipsize;
1959 mipsize_total = ddssize - 128 - (mippixels_start - ddspixels);
1960 mipsize = bytesperblock ? ((mipwidth+3)/4)*((mipheight+3)/4)*bytesperblock : mipwidth*mipheight*bytesperpixel;
1967 int mipsize_new = mipsize_total / bytesperblock * 4;
1969 unsigned char *p = mipnewpixels;
1970 for (
i = bytesperblock == 16 ? 8 : 0;
i < (
int)mipsize_total;
i += bytesperblock, p += 4)
1973 c = mippixels_start[
i] + 256u*mippixels_start[
i+1] + 65536u*mippixels_start[
i+2] + 16777216u*mippixels_start[
i+3];
1974 p[2] = (((c >> 11) & 0x1F) + ((c >> 27) & 0x1F)) * (0.5f / 31.0f * 255.0f);
1975 p[1] = (((c >> 5) & 0x3F) + ((c >> 21) & 0x3F)) * (0.5f / 63.0f * 255.0f);
1976 p[0] = (((c ) & 0x1F) + ((c >> 16) & 0x1F)) * (0.5f / 31.0f * 255.0f);
1978 p[3] = (0.5 * mippixels_start[
i-8] + 0.5 * mippixels_start[
i-7]);
1981 (mippixels_start[
i-8] & 0x0F)
1982 + (mippixels_start[
i-8] >> 4)
1983 + (mippixels_start[
i-7] & 0x0F)
1984 + (mippixels_start[
i-7] >> 4)
1985 + (mippixels_start[
i-6] & 0x0F)
1986 + (mippixels_start[
i-6] >> 4)
1987 + (mippixels_start[
i-5] & 0x0F)
1988 + (mippixels_start[
i-5] >> 4)
1989 ) * (0.125f / 15.0f * 255.0f);
1999 mipwidth = (mipwidth + 3) / 4;
2000 mipheight = (mipheight + 3) / 4;
2001 mipsize = bytesperpixel * mipwidth * mipheight;
2002 mippixels_start = mipnewpixels;
2003 mipsize_total = mipsize_new;
2007 mippixels = mippixels_start;
2016 for (
i = bytesperblock == 16 ? 8 : 0;
i < mipsize;
i += bytesperblock)
2019 c = mippixels[
i] + 256u*mippixels[
i+1] + 65536u*mippixels[
i+2] + 16777216u*mippixels[
i+3];
2020 avgcolor[0] += ((c >> 11) & 0x1F) + ((c >> 27) & 0x1F);
2021 avgcolor[1] += ((c >> 5) & 0x3F) + ((c >> 21) & 0x3F);
2022 avgcolor[2] += ((c ) & 0x1F) + ((c >> 16) & 0x1F);
2024 avgcolor[3] += (mippixels[
i-8] + (
int) mippixels[
i-7]) * (0.5f / 255.0f);
2027 (mippixels_start[
i-8] & 0x0F)
2028 + (mippixels_start[
i-8] >> 4)
2029 + (mippixels_start[
i-7] & 0x0F)
2030 + (mippixels_start[
i-7] >> 4)
2031 + (mippixels_start[
i-6] & 0x0F)
2032 + (mippixels_start[
i-6] >> 4)
2033 + (mippixels_start[
i-5] & 0x0F)
2034 + (mippixels_start[
i-5] >> 4)
2035 ) * (0.125f / 15.0f);
2037 avgcolor[3] += 1.0f;
2039 f = (
float)bytesperblock / mipsize;
2040 avgcolor[0] *= (0.5f / 31.0f) *
f;
2041 avgcolor[1] *= (0.5f / 63.0f) *
f;
2042 avgcolor[2] *= (0.5f / 31.0f) *
f;
2047 for (
i = 0;
i < mipsize;
i += 4)
2049 avgcolor[0] += mippixels[
i+2];
2050 avgcolor[1] += mippixels[
i+1];
2051 avgcolor[2] += mippixels[
i];
2052 avgcolor[3] += mippixels[
i+3];
2054 f = (1.0f / 255.0f) * bytesperpixel / mipsize;
2087 for (
i = bytesperblock == 16 ? 8 : 0;
i < mipsize_total;
i += bytesperblock)
2089 int c0, c1, c0new, c1new;
2090 c0 = mippixels_start[
i] + 256*mippixels_start[
i+1];
2091 r = ((c0 >> 11) & 0x1F);
2092 g = ((c0 >> 5) & 0x3F);
2097 c0new = (
r << 11) | (
g << 5) |
b;
2098 c1 = mippixels_start[
i+2] + 256*mippixels_start[
i+3];
2099 r = ((c1 >> 11) & 0x1F);
2100 g = ((c1 >> 5) & 0x3F);
2105 c1new = (
r << 11) | (
g << 5) |
b;
2115 mippixels_start[
i+4] ^= 0x55;
2116 mippixels_start[
i+5] ^= 0x55;
2117 mippixels_start[
i+6] ^= 0x55;
2118 mippixels_start[
i+7] ^= 0x55;
2120 else if(c0new == c1new)
2122 mippixels_start[
i+4] = 0x00;
2123 mippixels_start[
i+5] = 0x00;
2124 mippixels_start[
i+6] = 0x00;
2125 mippixels_start[
i+7] = 0x00;
2135 mippixels_start[
i+4] ^= (~mippixels_start[
i+4] >> 1) & 0x55;
2136 mippixels_start[
i+5] ^= (~mippixels_start[
i+5] >> 1) & 0x55;
2137 mippixels_start[
i+6] ^= (~mippixels_start[
i+6] >> 1) & 0x55;
2138 mippixels_start[
i+7] ^= (~mippixels_start[
i+7] >> 1) & 0x55;
2141 mippixels_start[
i] = c0new & 255;
2142 mippixels_start[
i+1] = c0new >> 8;
2143 mippixels_start[
i+2] = c1new & 255;
2144 mippixels_start[
i+3] = c1new >> 8;
2161 if (dds_miplevels >= 1)
2164 flags &= ~TEXF_MIPMAP;
2209 mipcomplete =
false;
2211 for (mip = 0;mip <= dds_miplevels;mip++)
2213 unsigned char *upload_mippixels = mippixels;
2214 int upload_mipwidth = mipwidth;
2215 int upload_mipheight = mipheight;
2216 mipsize = bytesperblock ? ((mipwidth+3)/4)*((mipheight+3)/4)*bytesperblock : mipwidth*mipheight*bytesperpixel;
2217 if (mippixels + mipsize > mippixels_start + mipsize_total)
2233 if(upload_mippixels != mippixels)
2235 mippixels += mipsize;
2236 if (mipwidth <= 1 && mipheight <= 1)
2252#ifdef GL_TEXTURE_MAX_LEVEL
2253 if (dds_miplevels >= 1 && !mipcomplete)
2266 Mem_Free((
unsigned char *) mippixels_start);
2289 Host_Error(
"R_UpdateTexture: no data supplied");
2291 Host_Error(
"R_UpdateTexture: no texture supplied");
2294 Con_DPrintf(
"R_UpdateTexture: texture %p \"%s\" in pool %p has not been uploaded yet\n", (
void *)glt, glt->
identifier, (
void *)glt->pool);
2304 Host_Error(
"R_UpdateTexture on buffered texture that is not 2D\n");
2305 if (
x < 0 ||
y < 0 ||
z < 0 || glt->tilewidth < x + width || glt->tileheight < y + height || glt->tiledepth <
z +
depth)
2308 for (j = 0; j < (size_t)
height; j++)
2417 return max(0, miplevel);
void CL_KeepaliveMessage(qbool readmessages)
cvar_t scr_screenshot_jpeg
cvar_t scr_screenshot_png
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
static int Cmd_Argc(cmd_state_t *cmd)
static const char * Cmd_Argv(cmd_state_t *cmd, int arg)
Cmd_Argv(cmd, ) will return an empty string (not a NULL) if arg > argc, so string operations are alwa...
#define CF_CLIENT
cvar/command that only the client can change/execute
#define CF_ARCHIVE
cvar should have its set value saved to config.cfg and persist across sessions
int BuffLittleLong(const unsigned char *buffer)
Extract a little endian 32bit int from the given buffer.
void StoreLittleLong(unsigned char *buffer, unsigned int i)
Encode a little endian 32bit int to the given buffer.
#define dp_strlcpy(dst, src, dsize)
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
void Log_Printf(const char *logfilename, const char *fmt,...)
void Cvar_SetValueQuick(cvar_t *var, float value)
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
qbool FS_WriteFile(const char *filename, const void *data, fs_offset_t len)
void FS_DefaultExtension(char *path, const char *extension, size_t size_path)
unsigned char * FS_LoadFile(const char *path, mempool_t *pool, qbool quiet, fs_offset_t *filesizepointer)
static int(ZEXPORT *qz_inflate)(z_stream *strm
void FS_StripExtension(const char *in, char *out, size_t size_out)
void GL_ActiveTexture(unsigned int num)
int R_Mesh_TexBound(unsigned int unitnum, int id)
void R_Mesh_ClearBindingsForTexture(int texnum)
rtexture_t * r_texture_white
static textypeinfo_t textype_depth24stencil8
static textypeinfo_t textype_rgba_compress
static textypeinfo_t textype_sRGB_dxt1
void R_PurgeTexture(rtexture_t *rt)
static textypeinfo_t textype_bgra_compress
static textypeinfo_t * R_GetTexTypeInfo(textype_t textype, int flags)
int R_RealGetTexture(rtexture_t *rt)
void R_FreeTexturePool(rtexturepool_t **rtexturepool)
cvar_t gl_texturecompression_q3bsplightmaps
void R_ClearTexture(rtexture_t *rt)
int R_TextureFlags(rtexture_t *rt)
static void r_textures_shutdown(void)
static gltexturepool_t * gltexturepoolchain
static int gltexturetypedimensions[GLTEXTURETYPE_TOTAL]
static textypeinfo_t textype_sRGB_palette
static void GL_SetupTextureParameters(int flags, textype_t textype, int texturetype)
static void R_UploadPartialTexture(gltexture_t *glt, const unsigned char *data, int fragx, int fragy, int fragz, int fragwidth, int fragheight, int fragdepth)
static void r_textures_newmap(void)
static textypeinfo_t textype_bgra_alpha
void R_MakeTextureDynamic(rtexture_t *rt, updatecallback_t updatecallback, void *data)
cvar_t gl_texturecompression_lightcubemaps
static textypeinfo_t textype_shadowmap16_raw
cvar_t gl_texturecompression
static textypeinfo_t textype_sRGB_bgra_alpha
static textypeinfo_t textype_rgba_alpha_compress
static memexpandablearray_t texturearray
static textypeinfo_t textype_sRGB_bgra_compress
static textypeinfo_t textype_alpha
rtexture_t * R_LoadTextureRenderBuffer(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, textype_t textype)
cvar_t r_texture_dds_swdecode
static mempool_t * texturemempool
static void r_textures_devicerestored(void)
static textypeinfo_t textype_colorbuffer
static textypeinfo_t textype_dxt5
static textypeinfo_t textype_sRGB_bgra_alpha_compress
cvar_t gl_texturecompression_sprites
int R_TextureHeight(rtexture_t *rt)
static void GL_Texture_CalcImageSize(int texturetype, int flags, int miplevel, int inwidth, int inheight, int indepth, int *outwidth, int *outheight, int *outdepth, int *outmiplevels)
cvar_t gl_texturecompression_sky
static textypeinfo_t textype_dxt1a
static textypeinfo_t textype_sRGB_rgba_alpha_compress
void R_UpdateTexture(rtexture_t *rt, const unsigned char *data, int x, int y, int z, int width, int height, int depth, int combine)
void R_TextureStats_Print(qbool printeach, qbool printpool, qbool printtotal)
static textypeinfo_t textype_rgba
static textypeinfo_t textype_sRGB_dxt3
static unsigned char * resizebuffer
rtexture_t * R_LoadTextureShadowMap2D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, textype_t textype, qbool filter)
static textypeinfo_t textype_sRGB_palette_alpha
static textypeinfo_t textype_bgra
static textypeinfo_t textype_sRGB_bgra
static textypeinfo_t textype_rgba_alpha
static int cubemapside[6]
static void R_UpdateDynamicTexture(gltexture_t *glt)
static textypeinfo_t textype_sRGB_rgba_alpha
cvar_t gl_texturecompression_reflectmask
int R_TextureWidth(rtexture_t *rt)
static textypeinfo_t textype_shadowmap16_comp
static rtexture_t * R_SetupTexture(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, int depth, int sides, int flags, int miplevel, textype_t textype, int texturetype, const unsigned char *data, const unsigned int *palette)
cvar_t gl_texturecompression_color
static const unsigned char * texturebuffer
rtexture_t * R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filename, qbool srgb, int flags, qbool *hasalphaflag, float *avgcolor, int miplevel, qbool optionaltexture)
static textypeinfo_t textype_bgra_alpha_compress
static textypeinfo_t textype_colorbuffer16f
static textypeinfo_t textype_palette
static void GL_TextureMode_f(cmd_state_t *cmd)
static textypeinfo_t textype_palette_alpha
static void r_textures_start(void)
static textypeinfo_t textype_sRGB_rgba_compress
#define TEXTUREPOOL_SENTINEL
int R_SaveTextureDDSFile(rtexture_t *rt, const char *filename, qbool skipuncompressed, qbool hasalpha)
static textypeinfo_t textype_shadowmap24_raw
cvar_t gl_texturecompression_glow
static textypeinfo_t textype_sRGB_rgba
static int gltexturetypeenums[GLTEXTURETYPE_TOTAL]
static void r_textures_devicelost(void)
rtexture_t * R_LoadTextureCubeMap(rtexturepool_t *rtexturepool, const char *identifier, int width, const unsigned char *data, textype_t textype, int flags, int miplevel, const unsigned int *palette)
rtexturepool_t * R_AllocTexturePool(void)
void R_FreeTexture(rtexture_t *rt)
cvar_t r_texture_dds_load_alphamode
static textypeinfo_t textype_dxt3
static textypeinfo_t textype_colorbuffer32f
cvar_t r_texture_dds_load_logfailure
cvar_t gl_texturecompression_2d
void R_Textures_Init(void)
cvar_t gl_texture_anisotropy
static void R_MakeResizeBufferBigger(int size)
static textypeinfo_t textype_sRGB_dxt1a
static textypeinfo_t textype_depth16
void R_MarkDirtyTexture(rtexture_t *rt)
rtexture_t * R_LoadTexture3D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, int depth, const unsigned char *data, textype_t textype, int flags, int miplevel, const unsigned int *palette)
static void R_UploadFullTexture(gltexture_t *glt, const unsigned char *data)
cvar_t gl_texturecompression_q3bspdeluxemaps
cvar_t gl_max_lightmapsize
static int R_CalcTexelDataSize(gltexture_t *glt)
void R_Textures_Frame(void)
static textypeinfo_t textype_dxt1
cvar_t gl_texturecompression_gloss
int R_PicmipForFlags(int flags)
static textypeinfo_t textype_sRGB_dxt5
static textypeinfo_t textype_depth24
static textypeinfo_t textype_shadowmap24_comp
static unsigned char * colorconvertbuffer
static void R_TextureStats_f(cmd_state_t *cmd)
static int resizebuffersize
rtexture_t * R_LoadTexture2D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, const unsigned char *data, textype_t textype, int flags, int miplevel, const unsigned int *palette)
cvar_t gl_texturecompression_normal
#define GL_TEXTURE_MAX_ANISOTROPY_EXT
GLubyte GLubyte GLubyte z
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y
#define GL_TEXTURE_COMPARE_FUNC
GLenum GLsizei GLsizei height
#define GL_TEXTURE_MIN_FILTER
#define GL_TEXTURE_WRAP_R
#define GL_COMPARE_R_TO_TEXTURE
#define GL_DEPTH24_STENCIL8
#define GL_TEXTURE_WRAP_S
#define GL_DEPTH_COMPONENT16
#define GL_TEXTURE_CUBE_MAP
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
#define GL_NEAREST_MIPMAP_NEAREST
#define GL_UNSIGNED_SHORT
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
#define GL_TEXTURE_MAX_LEVEL
#define GL_PACK_ALIGNMENT
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLint GLenum GLint GLint y
#define GL_NEAREST_MIPMAP_LINEAR
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
GLint GLenum GLsizei GLsizei GLsizei depth
#define GL_UNSIGNED_INT_24_8
#define GL_LINEAR_MIPMAP_LINEAR
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT
#define GL_TEXTURE_COMPRESSION_HINT
GLsizeiptr const GLvoid * data
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
#define GL_UNPACK_ALIGNMENT
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z
#define GL_LINEAR_MIPMAP_NEAREST
#define GL_TEXTURE_INTERNAL_FORMAT
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
#define GL_DEPTH_COMPONENT
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X
#define GL_TEXTURE_WRAP_T
#define GL_TEXTURE_MAG_FILTER
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
#define GL_DEPTH_COMPONENT24
#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X
#define GL_TEXTURE_COMPARE_MODE
void Host_Error(const char *error,...)
void Image_MakeLinearColorsFromsRGB(unsigned char *pout, const unsigned char *pin, int numpixels)
void Image_Resample32(const void *indata, int inwidth, int inheight, int indepth, void *outdata, int outwidth, int outheight, int outdepth, int quality)
void Image_Copy8bitBGRA(const unsigned char *in, unsigned char *out, int pixels, const unsigned int *pal)
void Image_MipReduce32(const unsigned char *in, unsigned char *out, int *width, int *height, int *depth, int destwidth, int destheight, int destdepth)
void Image_CopyMux(unsigned char *outpixels, const unsigned char *inpixels, int inputwidth, int inputheight, qbool inputflipx, qbool inputflipy, qbool inputflipdiagonal, int numoutputcomponents, int numinputcomponents, int *outputinputcomponentindices)
#define Image_LinearFloatFromsRGB(c)
qbool PNG_OpenLibrary(void)
qbool JPEG_OpenLibrary(void)
void JPEG_CloseLibrary(void)
#define bound(min, num, max)
#define INTOVERFLOW_ADD(a, b)
#define INTOVERFLOW_NORMALIZE(a)
#define INTOVERFLOW_MUL(a, b)
#define MAX_QPATH
max length of a quake game pathname
#define INTOVERFLOW_DIV(a, b)
void R_RegisterModule(const char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void))
#define TEXF_RGBMULTIPLYBYALPHA
#define TEXF_ALLOWUPDATES
#define TEXF_FORCENEAREST
@ TEXTYPE_SHADOWMAP16_RAW
@ TEXTYPE_SHADOWMAP16_COMP
@ TEXTYPE_SHADOWMAP24_RAW
@ TEXTYPE_DEPTHBUFFER24STENCIL8
@ TEXTYPE_SHADOWMAP24_COMP
void(* updatecallback_t)(rtexture_t *rt, void *data)
#define TEXF_RENDERTARGET
command interpreter state - the tokenizing and execution of commands, as well as pointers to which cv...
const unsigned int * palette
char identifier[MAX_QPATH+32]
struct gltexturepool_s * pool
unsigned char * bufferpixels
struct gltexture_s * chain
void * updatecallback_data
updatecallback_t updatecallback
unsigned char * inputtexels
struct gltexture_s * gltchain
struct gltexturepool_s * next
int internalbytesperpixel
float glinternalbytesperpixel
qbool ext_texture_filter_anisotropic
qbool ext_texture_compression_s3tc
unsigned int maxtexturesize_2d
int forcetextype
always use GL_BGRA for D3D, always use GL_RGBA for GLES, etc
unsigned int maxtexturesize_3d
unsigned int maxtexturesize_cubemap
unsigned int max_anisotropy
void Sys_Error(const char *error,...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN
Causes the entire program to exit ASAP.
const char * gl_version
begins with 1.0.0, 1.1.0, 1.2.0, 1.2.1, 1.3.0, 1.3.1, or 1.4.0
viddef_t vid
global video state
size_t Mem_ExpandableArray_IndexRange(const memexpandablearray_t *l)
void Mem_ExpandableArray_NewArray(memexpandablearray_t *l, mempool_t *mempool, size_t recordsize, int numrecordsperarray)
void Mem_ExpandableArray_FreeRecord(memexpandablearray_t *l, void *record)
void * Mem_ExpandableArray_AllocRecord(memexpandablearray_t *l)
void * Mem_ExpandableArray_RecordAtIndex(const memexpandablearray_t *l, size_t index)
void Mem_ExpandableArray_FreeArray(memexpandablearray_t *l)
#define Mem_FreePool(pool)
#define Mem_Alloc(pool, size)
#define Mem_AllocPool(name, flags, parent)