static cachepic_t cachepics[MAX_CACHED_PICS];
static int numcachepics;
-static rtexturepool_t *drawtexturepool;
+rtexturepool_t *drawtexturepool;
static const unsigned char concharimage[FONT_FILESIZE] =
{
return r_texture_notexture;
}
+int draw_frame = 1;
/*
================
cachepic_t *Draw_CachePic_Flags(const char *path, unsigned int cachepicflags)
{
int crc, hashkey;
- unsigned char *pixels;
+ unsigned char *pixels = NULL;
cachepic_t *pic;
fs_offset_t lmpsize;
unsigned char *lmpdata;
char lmpname[MAX_QPATH];
int texflags;
int j;
+ qboolean ddshasalpha;
+ float ddsavgcolor[4];
+ qboolean loaded = false;
texflags = TEXF_ALPHA;
if (!(cachepicflags & CACHEPICFLAG_NOCLAMP))
texflags |= TEXF_CLAMP;
- if (!(cachepicflags & CACHEPICFLAG_NOCOMPRESSION) && gl_texturecompression_2d.integer)
+ if (!(cachepicflags & CACHEPICFLAG_NOCOMPRESSION) && gl_texturecompression_2d.integer && gl_texturecompression.integer)
texflags |= TEXF_COMPRESS;
// check whether the picture has already been cached
pic->hasalpha = true; // assume alpha unless we know it has none
pic->texflags = texflags;
pic->autoload = (cachepicflags & CACHEPICFLAG_NOTPERSISTENT);
+ pic->lastusedframe = draw_frame;
// load a high quality image from disk if possible
- pixels = loadimagepixelsbgra(path, false, true, r_texture_convertsRGB_2d.integer != 0, NULL);
- if (pixels == NULL && !strncmp(path, "gfx/", 4))
- pixels = loadimagepixelsbgra(path+4, false, true, r_texture_convertsRGB_2d.integer != 0, NULL);
- if (pixels)
+ if (!loaded && r_texture_dds_load.integer != 0 && (pic->tex = R_LoadTextureDDSFile(drawtexturepool, va("dds/%s.dds", pic->name), pic->texflags, &ddshasalpha, ddsavgcolor, 0)))
+ {
+ // note this loads even if autoload is true, otherwise we can't get the width/height
+ loaded = true;
+ pic->hasalpha = ddshasalpha;
+ pic->width = R_TextureWidth(pic->tex);
+ pic->height = R_TextureHeight(pic->tex);
+ }
+ if (!loaded && ((pixels = loadimagepixelsbgra(pic->name, false, true, false, NULL)) || (!strncmp(pic->name, "gfx/", 4) && (pixels = loadimagepixelsbgra(pic->name+4, false, true, false, NULL)))))
{
+ loaded = true;
pic->hasalpha = false;
if (pic->texflags & TEXF_ALPHA)
{
pic->width = image_width;
pic->height = image_height;
if (!pic->autoload)
- pic->tex = R_LoadTexture2D(drawtexturepool, path, image_width, image_height, pixels, TEXTYPE_BGRA, pic->texflags & (pic->hasalpha ? ~0 : ~TEXF_ALPHA), -1, NULL);
+ {
+ pic->tex = R_LoadTexture2D(drawtexturepool, pic->name, image_width, image_height, pixels, vid.sRGB2D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, pic->texflags & (pic->hasalpha ? ~0 : ~TEXF_ALPHA), -1, NULL);
+ if (r_texture_dds_save.integer && qglGetCompressedTexImageARB && pic->tex)
+ R_SaveTextureDDSFile(pic->tex, va("dds/%s.dds", pic->name), r_texture_dds_save.integer < 2, pic->hasalpha);
+ }
}
- else
+ if (!loaded)
{
pic->autoload = false;
// never compress the fallback images
// size from that even if we don't upload the texture, this way the pics
// show up the right size in the menu even if they were replaced with
// higher or lower resolution versions
- dpsnprintf(lmpname, sizeof(lmpname), "%s.lmp", path);
- if (!strncmp(path, "gfx/", 4) && (lmpdata = FS_LoadFile(lmpname, tempmempool, false, &lmpsize)))
+ dpsnprintf(lmpname, sizeof(lmpname), "%s.lmp", pic->name);
+ if (!strncmp(pic->name, "gfx/", 4) && (lmpdata = FS_LoadFile(lmpname, tempmempool, false, &lmpsize)))
{
if (developer_loading.integer)
- Con_Printf("loading lump \"%s\"\n", path);
+ Con_Printf("loading lump \"%s\"\n", pic->name);
if (lmpsize >= 9)
{
pic->width = lmpdata[0] + lmpdata[1] * 256 + lmpdata[2] * 65536 + lmpdata[3] * 16777216;
pic->height = lmpdata[4] + lmpdata[5] * 256 + lmpdata[6] * 65536 + lmpdata[7] * 16777216;
// if no high quality replacement image was found, upload the original low quality texture
- if (!pixels)
- pic->tex = R_LoadTexture2D(drawtexturepool, path, pic->width, pic->height, lmpdata + 8, TEXTYPE_PALETTE, pic->texflags, -1, palette_bgra_transparent);
+ if (!loaded)
+ {
+ loaded = true;
+ pic->tex = R_LoadTexture2D(drawtexturepool, pic->name, pic->width, pic->height, lmpdata + 8, vid.sRGB2D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, pic->texflags, -1, palette_bgra_transparent);
+ }
}
Mem_Free(lmpdata);
}
- else if ((lmpdata = W_GetLumpName (path + 4)))
+ else if ((lmpdata = W_GetLumpName (pic->name + 4)))
{
if (developer_loading.integer)
- Con_Printf("loading gfx.wad lump \"%s\"\n", path + 4);
+ Con_Printf("loading gfx.wad lump \"%s\"\n", pic->name + 4);
- if (!strcmp(path, "gfx/conchars"))
+ if (!strcmp(pic->name, "gfx/conchars"))
{
// conchars is a raw image and with color 0 as transparent instead of 255
pic->width = 128;
pic->height = 128;
// if no high quality replacement image was found, upload the original low quality texture
- if (!pixels)
- pic->tex = R_LoadTexture2D(drawtexturepool, path, 128, 128, lmpdata, TEXTYPE_PALETTE, pic->texflags, -1, palette_bgra_font);
+ if (!loaded)
+ {
+ loaded = true;
+ pic->tex = R_LoadTexture2D(drawtexturepool, pic->name, 128, 128, lmpdata, vid.sRGB2D != 0 ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, pic->texflags, -1, palette_bgra_font);
+ }
}
else
{
pic->width = lmpdata[0] + lmpdata[1] * 256 + lmpdata[2] * 65536 + lmpdata[3] * 16777216;
pic->height = lmpdata[4] + lmpdata[5] * 256 + lmpdata[6] * 65536 + lmpdata[7] * 16777216;
// if no high quality replacement image was found, upload the original low quality texture
- if (!pixels)
- pic->tex = R_LoadTexture2D(drawtexturepool, path, pic->width, pic->height, lmpdata + 8, TEXTYPE_PALETTE, pic->texflags, -1, palette_bgra_transparent);
+ if (!loaded)
+ {
+ loaded = true;
+ pic->tex = R_LoadTexture2D(drawtexturepool, pic->name, pic->width, pic->height, lmpdata + 8, vid.sRGB2D != 0 ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, pic->texflags, -1, palette_bgra_transparent);
+ }
}
}
Mem_Free(pixels);
pixels = NULL;
}
- else if (pic->tex == NULL)
+ if (!loaded)
{
// if it's not found on disk, generate an image
- pic->tex = draw_generatepic(path, (cachepicflags & CACHEPICFLAG_QUIET) != 0);
+ pic->tex = draw_generatepic(pic->name, (cachepicflags & CACHEPICFLAG_QUIET) != 0);
pic->width = R_TextureWidth(pic->tex);
pic->height = R_TextureHeight(pic->tex);
}
return Draw_CachePic_Flags (path, 0); // default to persistent!
}
-int draw_frame = 1;
-
rtexture_t *Draw_GetPicTexture(cachepic_t *pic)
{
if (pic->autoload && !pic->tex)
{
- pic->tex = loadtextureimage(drawtexturepool, pic->name, false, pic->texflags, true, r_texture_convertsRGB_2d.integer != 0);
+ if (pic->tex == NULL && r_texture_dds_load.integer != 0)
+ {
+ qboolean ddshasalpha;
+ float ddsavgcolor[4];
+ pic->tex = R_LoadTextureDDSFile(drawtexturepool, va("dds/%s.dds", pic->name), pic->texflags, &ddshasalpha, ddsavgcolor, 0);
+ }
+ if (pic->tex == NULL)
+ {
+ pic->tex = loadtextureimage(drawtexturepool, pic->name, false, pic->texflags, true, vid.sRGB2D);
+ if (r_texture_dds_save.integer && qglGetCompressedTexImageARB && pic->tex)
+ R_SaveTextureDDSFile(pic->tex, va("dds/%s.dds", pic->name), r_texture_dds_save.integer < 2, pic->hasalpha);
+ }
if (pic->tex == NULL && !strncmp(pic->name, "gfx/", 4))
- pic->tex = loadtextureimage(drawtexturepool, pic->name+4, false, pic->texflags, true, r_texture_convertsRGB_2d.integer != 0);
+ {
+ pic->tex = loadtextureimage(drawtexturepool, pic->name+4, false, pic->texflags, true, vid.sRGB2D);
+ if (r_texture_dds_save.integer && qglGetCompressedTexImageARB && pic->tex)
+ R_SaveTextureDDSFile(pic->tex, va("dds/%s.dds", pic->name), r_texture_dds_save.integer < 2, pic->hasalpha);
+ }
if (pic->tex == NULL)
pic->tex = draw_generatepic(pic->name, true);
}
{
if (pic->tex && pic->width == width && pic->height == height)
{
- R_UpdateTexture(pic->tex, pixels_bgra, 0, 0, width, height);
+ R_UpdateTexture(pic->tex, pixels_bgra, 0, 0, 0, width, height, 1);
return pic;
}
}
r_refdef.draw2dstage = 1;
CHECKGLERROR
R_Viewport_InitOrtho(&viewport, &identitymatrix, r_refdef.view.x, vid.height - r_refdef.view.y - r_refdef.view.height, r_refdef.view.width, r_refdef.view.height, 0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100, NULL);
+ R_Mesh_ResetRenderTargets();
R_SetViewport(&viewport);
GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
GL_DepthFunc(GL_LEQUAL);
GL_PolygonOffset(0, 0);
GL_DepthTest(false);
GL_Color(1,1,1,1);
- GL_AlphaTest(false);
}
qboolean r_draw2d_force = false;
return x;
}
+float DrawQ_Color[4];
float DrawQ_String_Scale(float startx, float starty, const char *text, size_t maxlen, float w, float h, float sw, float sh, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor, qboolean ignorecolorcodes, const dp_font_t *fnt)
{
int shadow, colorindex = STRING_COLOR_DEFAULT;
size_t i;
float x = startx, y, s, t, u, v, thisw;
float *av, *at, *ac;
- float color[4];
int batchcount;
static float vertex3f[QUADELEMENTS_MAXQUADS*4*3];
static float texcoord2f[QUADELEMENTS_MAXQUADS*4*2];
else
colorindex = *outcolor;
- DrawQ_GetTextColor(color, colorindex, basered, basegreen, baseblue, basealpha, shadow != 0);
+ DrawQ_GetTextColor(DrawQ_Color, colorindex, basered, basegreen, baseblue, basealpha, shadow != 0);
x = startx;
y = starty;
if (ch <= '9' && ch >= '0') // ^[0-9] found
{
colorindex = ch - '0';
- DrawQ_GetTextColor(color, colorindex, basered, basegreen, baseblue, basealpha, shadow != 0);
+ DrawQ_GetTextColor(DrawQ_Color, colorindex, basered, basegreen, baseblue, basealpha, shadow != 0);
++text;
++i;
continue;
colorindex = tempcolorindex | 0xf;
// ...done! now colorindex has rgba codes (1,rrrr,gggg,bbbb,aaaa)
//Con_Printf("^1colorindex:^7 %x\n", colorindex);
- DrawQ_GetTextColor(color, colorindex, basered, basegreen, baseblue, basealpha, shadow != 0);
+ DrawQ_GetTextColor(DrawQ_Color, colorindex, basered, basegreen, baseblue, basealpha, shadow != 0);
i+=4;
text+=4;
continue;
t = (ch >> 4)*0.0625f + (0.5f / th);
u = 0.0625f * thisw - (1.0f / tw);
v = 0.0625f - (1.0f / th);
- ac[ 0] = color[0];ac[ 1] = color[1];ac[ 2] = color[2];ac[ 3] = color[3];
- ac[ 4] = color[0];ac[ 5] = color[1];ac[ 6] = color[2];ac[ 7] = color[3];
- ac[ 8] = color[0];ac[ 9] = color[1];ac[10] = color[2];ac[11] = color[3];
- ac[12] = color[0];ac[13] = color[1];ac[14] = color[2];ac[15] = color[3];
+ ac[ 0] = DrawQ_Color[0];ac[ 1] = DrawQ_Color[1];ac[ 2] = DrawQ_Color[2];ac[ 3] = DrawQ_Color[3];
+ ac[ 4] = DrawQ_Color[0];ac[ 5] = DrawQ_Color[1];ac[ 6] = DrawQ_Color[2];ac[ 7] = DrawQ_Color[3];
+ ac[ 8] = DrawQ_Color[0];ac[ 9] = DrawQ_Color[1];ac[10] = DrawQ_Color[2];ac[11] = DrawQ_Color[3];
+ ac[12] = DrawQ_Color[0];ac[13] = DrawQ_Color[1];ac[14] = DrawQ_Color[2];ac[15] = DrawQ_Color[3];
at[ 0] = s ; at[ 1] = t ;
at[ 2] = s+u ; at[ 3] = t ;
at[ 4] = s+u ; at[ 5] = t+v ;
break;
}
}
- R_SetupShader_Generic(map->texture, NULL, GL_MODULATE, 1);
+ R_SetupShader_Generic(map->pic->tex, NULL, GL_MODULATE, 1);
}
mapch = ch - map->start;
}
else
kx = ky = 0;
- ac[ 0] = color[0]; ac[ 1] = color[1]; ac[ 2] = color[2]; ac[ 3] = color[3];
- ac[ 4] = color[0]; ac[ 5] = color[1]; ac[ 6] = color[2]; ac[ 7] = color[3];
- ac[ 8] = color[0]; ac[ 9] = color[1]; ac[10] = color[2]; ac[11] = color[3];
- ac[12] = color[0]; ac[13] = color[1]; ac[14] = color[2]; ac[15] = color[3];
+ ac[ 0] = DrawQ_Color[0]; ac[ 1] = DrawQ_Color[1]; ac[ 2] = DrawQ_Color[2]; ac[ 3] = DrawQ_Color[3];
+ ac[ 4] = DrawQ_Color[0]; ac[ 5] = DrawQ_Color[1]; ac[ 6] = DrawQ_Color[2]; ac[ 7] = DrawQ_Color[3];
+ ac[ 8] = DrawQ_Color[0]; ac[ 9] = DrawQ_Color[1]; ac[10] = DrawQ_Color[2]; ac[11] = DrawQ_Color[3];
+ ac[12] = DrawQ_Color[0]; ac[13] = DrawQ_Color[1]; ac[14] = DrawQ_Color[2]; ac[15] = DrawQ_Color[3];
at[0] = map->glyphs[mapch].txmin; at[1] = map->glyphs[mapch].tymin;
at[2] = map->glyphs[mapch].txmax; at[3] = map->glyphs[mapch].tymin;
at[4] = map->glyphs[mapch].txmax; at[5] = map->glyphs[mapch].tymax;
if (outcolor)
*outcolor = colorindex;
-
+
// note: this relies on the proper text (not shadow) being drawn last
return x;
}
case RENDERPATH_GL11:
case RENDERPATH_GL13:
case RENDERPATH_GL20:
- case RENDERPATH_CGGL:
CHECKGLERROR
qglBegin(GL_LINE_LOOP);
for (num = 0;num < mesh->num_vertices;num++)
case RENDERPATH_D3D11:
Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
+ case RENDERPATH_SOFT:
+ //Con_DPrintf("FIXME SOFT %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
+ break;
+ case RENDERPATH_GLES1:
+ case RENDERPATH_GLES2:
+ //Con_DPrintf("FIXME GLES2 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
+ return;
}
}
case RENDERPATH_GL11:
case RENDERPATH_GL13:
case RENDERPATH_GL20:
- case RENDERPATH_CGGL:
CHECKGLERROR
//qglLineWidth(width);CHECKGLERROR
case RENDERPATH_D3D11:
Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
+ case RENDERPATH_SOFT:
+ //Con_DPrintf("FIXME SOFT %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
+ break;
+ case RENDERPATH_GLES1:
+ case RENDERPATH_GLES2:
+ //Con_DPrintf("FIXME GLES2 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
+ return;
}
}
case RENDERPATH_GL11:
case RENDERPATH_GL13:
case RENDERPATH_GL20:
- case RENDERPATH_CGGL:
CHECKGLERROR
R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
case RENDERPATH_D3D11:
Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
+ case RENDERPATH_SOFT:
+ //Con_DPrintf("FIXME SOFT %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
+ break;
+ case RENDERPATH_GLES1:
+ case RENDERPATH_GLES2:
+ //Con_DPrintf("FIXME GLES2 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
+ return;
}
}
iy = (int)(0.5 + y * ((float) vid.height / vid_conheight.integer));
iw = (int)(0.5 + (x+width) * ((float)vid.width / vid_conwidth.integer)) - ix;
ih = (int)(0.5 + (y+height) * ((float) vid.height / vid_conheight.integer)) - iy;
- GL_Scissor(ix, vid.height - iy - ih, iw, ih);
+ switch(vid.renderpath)
+ {
+ case RENDERPATH_GL11:
+ case RENDERPATH_GL13:
+ case RENDERPATH_GL20:
+ case RENDERPATH_GLES1:
+ case RENDERPATH_GLES2:
+ case RENDERPATH_SOFT:
+ GL_Scissor(ix, vid.height - iy - ih, iw, ih);
+ break;
+ case RENDERPATH_D3D9:
+ GL_Scissor(ix, iy, iw, ih);
+ break;
+ case RENDERPATH_D3D10:
+ Con_DPrintf("FIXME D3D10 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
+ break;
+ case RENDERPATH_D3D11:
+ Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
+ break;
+ }
GL_ScissorTest(true);
}
switch(vid.renderpath)
{
case RENDERPATH_GL20:
- case RENDERPATH_CGGL:
case RENDERPATH_D3D9:
case RENDERPATH_D3D10:
case RENDERPATH_D3D11:
+ case RENDERPATH_GLES2:
if (vid_usinghwgamma || v_glslgamma.integer)
return;
break;
- case RENDERPATH_GL13:
case RENDERPATH_GL11:
+ case RENDERPATH_GL13:
if (vid_usinghwgamma)
return;
break;
+ case RENDERPATH_GLES1:
+ case RENDERPATH_SOFT:
+ return;
}
// all the blends ignore depth
// R_Mesh_ResetTextureState();