hashkey = ((crc >> 8) ^ crc) % CACHEPICHASHSIZE;
for (pic = cachepichash[hashkey];pic;pic = pic->chain)
if (!strcmp (path, pic->name))
- if(pic->texflags == texflags)
+ if(!((pic->texflags ^ texflags) & ~(TEXF_COMPRESS))) // ignore TEXF_COMPRESS when comparing, because fallback pics remove the flag
{
if(!(cachepicflags & CACHEPICFLAG_NOTPERSISTENT))
- pic->autoload = false; // persist it
+ {
+ if(pic->tex)
+ pic->autoload = false; // persist it
+ else
+ goto reload; // load it below, and then persist
+ }
return pic;
}
pic->chain = cachepichash[hashkey];
cachepichash[hashkey] = pic;
+reload:
// check whether it is an dynamic texture (if so, we can directly use its texture handler)
pic->tex = CL_GetDynTexture( path );
// if so, set the width/height, too
pic->height = height;
if (pic->tex)
R_FreeTexture(pic->tex);
- pic->tex = R_LoadTexture2D(drawtexturepool, picname, width, height, pixels_bgra, TEXTYPE_BGRA, (alpha ? TEXF_ALPHA : 0) | TEXF_ALLOWUPDATES, -1, NULL);
+ pic->tex = R_LoadTexture2D(drawtexturepool, picname, width, height, pixels_bgra, TEXTYPE_BGRA, (alpha ? TEXF_ALPHA : 0), -1, NULL);
return pic;
}
extern cvar_t developer_font;
dp_font_t *FindFont(const char *title, qboolean allocate_new)
{
- int i;
+ int i, oldsize;
// find font
for(i = 0; i < dp_fonts.maxsize; ++i)
}
}
// if no any 'free' fonts - expand buffer
- i = dp_fonts.maxsize;
+ oldsize = dp_fonts.maxsize;
dp_fonts.maxsize = dp_fonts.maxsize + FONTS_EXPAND;
if (developer_font.integer)
- Con_Printf("FindFont: enlarging fonts buffer (%i -> %i)\n", i, dp_fonts.maxsize);
+ Con_Printf("FindFont: enlarging fonts buffer (%i -> %i)\n", oldsize, dp_fonts.maxsize);
dp_fonts.f = (dp_font_t *)Mem_Realloc(fonts_mempool, dp_fonts.f, sizeof(dp_font_t) * dp_fonts.maxsize);
+ // relink ft2 structures
+ for(i = 0; i < oldsize; ++i)
+ if (dp_fonts.f[i].ft2)
+ dp_fonts.f[i].ft2->settings = &dp_fonts.f[i].settings;
// register a font in first expanded slot
- strlcpy(dp_fonts.f[i].title, title, sizeof(dp_fonts.f[i].title));
- return &dp_fonts.f[i];
+ strlcpy(dp_fonts.f[oldsize].title, title, sizeof(dp_fonts.f[oldsize].title));
+ return &dp_fonts.f[oldsize];
}
return NULL;
}
voffset = atof(Cmd_Argv(i));
continue;
}
+
+ if (sizes == -1)
+ continue; // no slot for other sizes
+
// parse one of sizes
sz = atof(Cmd_Argv(i));
if (sz > 0.001f && sz < 1000.0f) // do not use crap sizes
{
+ // search for duplicated sizes
+ int j;
+ for (j=0; j<sizes; j++)
+ if (f->req_sizes[j] == sz)
+ break;
+ if (j != sizes)
+ continue; // sz already in req_sizes, don't add it again
+
+ if (sizes == MAX_FONT_SIZES)
+ {
+ Con_Printf("Warning: specified more than %i different font sizes, exceding ones are ignored\n", MAX_FONT_SIZES);
+ sizes = -1;
+ continue;
+ }
f->req_sizes[sizes] = sz;
sizes++;
}
static void _DrawQ_Setup(void)
{
r_viewport_t viewport;
- if (r_refdef.draw2dstage)
+ if (r_refdef.draw2dstage == 1)
return;
- r_refdef.draw2dstage = true;
+ 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_SetViewport(&viewport);
void DrawQ_Finish(void)
{
- r_refdef.draw2dstage = false;
+ r_refdef.draw2dstage = 0;
+}
+
+void DrawQ_RecalcView(void)
+{
+ if(r_refdef.draw2dstage)
+ r_refdef.draw2dstage = -1; // next draw call will set viewport etc. again
}
static float blendvertex3f[9] = {-5000, -5000, 10, 10000, -5000, 10, -5000, 10000, 10};