texflags |= TEXF_MIPMAP;
if (!(cachepicflags & CACHEPICFLAG_NOCOMPRESSION) && gl_texturecompression_2d.integer && gl_texturecompression.integer)
texflags |= TEXF_COMPRESS;
- if ((cachepicflags & CACHEPICFLAG_NEAREST) || r_nearest_2d.integer)
+ if (cachepicflags & CACHEPICFLAG_LINEAR)
+ texflags |= TEXF_FORCELINEAR;
+ else if ((cachepicflags & CACHEPICFLAG_NEAREST) || r_nearest_2d.integer)
texflags |= TEXF_FORCENEAREST;
// check whether the picture has already been cached
int i;
cachepic_t *pic;
static double nextpurgetime;
- if (nextpurgetime > realtime)
+ if (nextpurgetime > host.realtime)
return;
- nextpurgetime = realtime + 0.05;
+ nextpurgetime = host.realtime + 0.05;
for (i = 0, pic = cachepics;i < numcachepics;i++, pic++)
{
if (pic->autoload && pic->skinframe && pic->skinframe->base && pic->lastusedframe < draw_frame - 3)
if (sizes == MAX_FONT_SIZES)
{
- Con_Warnf("Warning: specified more than %i different font sizes, exceding ones are ignored\n", MAX_FONT_SIZES);
+ Con_Printf(CON_WARN "Warning: specified more than %i different font sizes, exceding ones are ignored\n", MAX_FONT_SIZES);
sizes = -1;
continue;
}
for(i = 0; i < dp_fonts.maxsize; ++i)
if (dp_fonts.f[i].title[0])
LoadFont(false, va(vabuf, sizeof(vabuf), "gfx/font_%s", dp_fonts.f[i].title), &dp_fonts.f[i], 1, 0);
-
- // draw the loading screen so people have something to see in the newly opened window
- SCR_UpdateLoadingScreen(true, true);
}
static void gl_draw_shutdown(void)
if(!FONT_USER(i)->title[0])
dpsnprintf(FONT_USER(i)->title, sizeof(FONT_USER(i)->title), "user%d", j++);
- Cmd_AddCommand(&cmd_client, "loadfont", LoadFont_f, "loadfont function tganame loads a font; example: loadfont console gfx/veramono; loadfont without arguments lists the available functions");
+ Cmd_AddCommand(CMD_CLIENT, "loadfont", LoadFont_f, "loadfont function tganame loads a font; example: loadfont console gfx/veramono; loadfont without arguments lists the available functions");
R_RegisterModule("GL_Draw", gl_draw_start, gl_draw_shutdown, gl_draw_newmap, NULL, NULL);
}
}
}
+// returns a colorindex (format 0x1RGBA) if str is a valid RGB string
+// returns 0 otherwise
+static int RGBstring_to_colorindex(const char *str)
+{
+ Uchar ch;
+ int ind = 0x0001 << 4;
+ do {
+ if (*str <= '9' && *str >= '0')
+ ind |= (*str - '0');
+ else
+ {
+ ch = tolower(*str);
+ if (ch >= 'a' && ch <= 'f')
+ ind |= (ch - 87);
+ else
+ return 0;
+ }
+ ++str;
+ ind <<= 4;
+ } while(!(ind & 0x10000));
+ return ind | 0xf; // add costant alpha value
+}
+
// NOTE: this function always draws exactly one character if maxwidth <= 0
float DrawQ_TextWidth_UntilWidth_TrackColors_Scale(const char *text, size_t *maxlen, float w, float h, float sw, float sh, int *outcolor, qboolean ignorecolorcodes, const dp_font_t *fnt, float maxwidth)
{
const char *text_start = text;
- int colorindex = STRING_COLOR_DEFAULT;
+ int colorindex;
size_t i;
float x = 0;
Uchar ch, mapch, nextch;
Uchar prevch = 0; // used for kerning
- int tempcolorindex;
float kx;
int map_index = 0;
size_t bytes_left;
// maxwidth /= fnt->scale; // w and h are multiplied by it already
// ftbase_x = snap_to_pixel_x(0);
-
+
if(maxwidth <= 0)
{
least_one = true;
x += width_of[(int) ' '] * dw;
continue;
}
- // i points to the char after ^
if (ch == STRING_COLOR_TAG && !ignorecolorcodes && i < *maxlen)
{
ch = *text; // colors are ascii, so no u8_ needed
++i;
continue;
}
- // i points to the char after ^...
- // i+3 points to 3 in ^x123
- // i+3 == *maxlen would mean that char is missing
else if (ch == STRING_COLOR_RGB_TAG_CHAR && i + 3 < *maxlen ) // ^x found
{
- // building colorindex...
- ch = tolower(text[1]);
- tempcolorindex = 0x10000; // binary: 1,0000,0000,0000,0000
- if (ch <= '9' && ch >= '0') tempcolorindex |= (ch - '0') << 12;
- else if (ch >= 'a' && ch <= 'f') tempcolorindex |= (ch - 87) << 12;
- else tempcolorindex = 0;
+ const char *text_p = &text[1];
+ int tempcolorindex = RGBstring_to_colorindex(text_p);
if (tempcolorindex)
{
- ch = tolower(text[2]);
- if (ch <= '9' && ch >= '0') tempcolorindex |= (ch - '0') << 8;
- else if (ch >= 'a' && ch <= 'f') tempcolorindex |= (ch - 87) << 8;
- else tempcolorindex = 0;
- if (tempcolorindex)
- {
- ch = tolower(text[3]);
- if (ch <= '9' && ch >= '0') tempcolorindex |= (ch - '0') << 4;
- else if (ch >= 'a' && ch <= 'f') tempcolorindex |= (ch - 87) << 4;
- else tempcolorindex = 0;
- if (tempcolorindex)
- {
- colorindex = tempcolorindex | 0xf;
- // ...done! now colorindex has rgba codes (1,rrrr,gggg,bbbb,aaaa)
- i+=4;
- text += 4;
- continue;
- }
- }
+ colorindex = tempcolorindex;
+ i+=4;
+ text += 4;
+ continue;
}
}
- else if (ch == STRING_COLOR_TAG) // ^^ found, ignore the first ^ and go to print the second
+ else if (ch == STRING_COLOR_TAG) // ^^ found
{
i++;
text++;
float x = startx, y, s, t, u, v, thisw;
Uchar ch, mapch, nextch;
Uchar prevch = 0; // used for kerning
- int tempcolorindex;
int map_index = 0;
//ft2_font_map_t *prevmap = NULL; // the previous map
ft2_font_map_t *map = NULL; // the currently used map
}
else if (ch == STRING_COLOR_RGB_TAG_CHAR && i+3 < maxlen ) // ^x found
{
- // building colorindex...
- ch = tolower(text[1]);
- tempcolorindex = 0x10000; // binary: 1,0000,0000,0000,0000
- if (ch <= '9' && ch >= '0') tempcolorindex |= (ch - '0') << 12;
- else if (ch >= 'a' && ch <= 'f') tempcolorindex |= (ch - 87) << 12;
- else tempcolorindex = 0;
- if (tempcolorindex)
+ const char *text_p = &text[1];
+ int tempcolorindex = RGBstring_to_colorindex(text_p);
+ if(tempcolorindex)
{
- ch = tolower(text[2]);
- if (ch <= '9' && ch >= '0') tempcolorindex |= (ch - '0') << 8;
- else if (ch >= 'a' && ch <= 'f') tempcolorindex |= (ch - 87) << 8;
- else tempcolorindex = 0;
- if (tempcolorindex)
- {
- ch = tolower(text[3]);
- if (ch <= '9' && ch >= '0') tempcolorindex |= (ch - '0') << 4;
- else if (ch >= 'a' && ch <= 'f') tempcolorindex |= (ch - 87) << 4;
- else tempcolorindex = 0;
- if (tempcolorindex)
- {
- colorindex = tempcolorindex | 0xf;
- // ...done! now colorindex has rgba codes (1,rrrr,gggg,bbbb,aaaa)
- //Con_Printf("^1colorindex:^7 %x\n", colorindex);
- DrawQ_GetTextColor(DrawQ_Color, colorindex, basered, basegreen, baseblue, basealpha, shadow != 0);
- i+=4;
- text+=4;
- continue;
- }
- }
+ colorindex = tempcolorindex;
+ DrawQ_GetTextColor(DrawQ_Color, colorindex, basered, basegreen, baseblue, basealpha, shadow != 0);
+ i+=4;
+ text+=4;
+ continue;
}
}
else if (ch == STRING_COLOR_TAG)
if (outcolor)
*outcolor = colorindex;
-
+
// note: this relies on the proper text (not shadow) being drawn last
return x;
}
return;
}
- // this is roughly equivalent to R_Q1BSP_Draw, so the UI can use full material feature set
+ // this is roughly equivalent to R_Mod_Draw, so the UI can use full material feature set
r_refdef.view.colorscale = 1;
r_textureframe++; // used only by R_GetCurrentTexture
GL_DepthMask(false);