- dq = (drawqueue_t *)(r_refdef.drawqueue + pos);
- additive = (dq->flags & DRAWFLAG_ADDITIVE) != 0;
- color = dq->color;
- m.blendfunc1 = GL_SRC_ALPHA;
- if (additive)
- m.blendfunc2 = GL_ONE;
- else
- m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
- m.depthdisable = true;
- R_Mesh_MainState(&m);
-
- cr = (float) ((color >> 24) & 0xFF) * (1.0f / 255.0f) * r_colorscale;
- cg = (float) ((color >> 16) & 0xFF) * (1.0f / 255.0f) * r_colorscale;
- cb = (float) ((color >> 8) & 0xFF) * (1.0f / 255.0f) * r_colorscale;
- ca = (float) ( color & 0xFF) * (1.0f / 255.0f);
- x = dq->x;
- y = dq->y;
- w = dq->scalex;
- h = dq->scaley;
-
- switch(dq->command)
- {
- case DRAWQUEUE_PIC:
- str = (char *)(dq + 1);
- if (strcmp(str, currentpic))
- {
- currentpic = str;
- if (*str)
- {
- pic = Draw_CachePic(str);
- m.tex[0] = R_GetTexture(pic->tex);
- }
- else
- m.tex[0] = 0;
- R_Mesh_TextureState(&m);
- }
- if (*str)
- {
- if (w == 0)
- w = pic->width;
- if (h == 0)
- h = pic->height;
- }
- varray_color[0] = varray_color[4] = varray_color[ 8] = varray_color[12] = cr;
- varray_color[1] = varray_color[5] = varray_color[ 9] = varray_color[13] = cg;
- varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = cb;
- varray_color[3] = varray_color[7] = varray_color[11] = varray_color[15] = ca;
- varray_texcoord[0][0] = 0;varray_texcoord[0][1] = 0;
- varray_texcoord[0][2] = 1;varray_texcoord[0][3] = 0;
- varray_texcoord[0][4] = 1;varray_texcoord[0][5] = 1;
- varray_texcoord[0][6] = 0;varray_texcoord[0][7] = 1;
- varray_vertex[ 0] = x ;varray_vertex[ 1] = y ;varray_vertex[ 2] = 10;
- varray_vertex[ 4] = x+w;varray_vertex[ 5] = y ;varray_vertex[ 6] = 10;
- varray_vertex[ 8] = x+w;varray_vertex[ 9] = y+h;varray_vertex[10] = 10;
- varray_vertex[12] = x ;varray_vertex[13] = y+h;varray_vertex[14] = 10;
- R_Mesh_Draw(4, 2, quadelements);
- break;
- case DRAWQUEUE_STRING:
- str = (char *)(dq + 1);
- if (strcmp("gfx/conchars", currentpic))
- {
- currentpic = "gfx/conchars";
- m.tex[0] = chartexnum;
- R_Mesh_TextureState(&m);
+ GL_LockArrays(0, batchcount * 4);
+ R_Mesh_Draw(0, batchcount * 4, batchcount * 2, quadelements);
+ GL_LockArrays(0, 0);
+ }
+}
+
+void DrawQ_String(float x, float y, const char *string, int maxlen, float scalex, float scaley, float red, float green, float blue, float alpha, int flags)
+{
+ float shadow;
+ if (r_textshadow.integer) {
+ shadow = (1-((red+green+blue)));
+ shadow = bound(0, shadow, 1);
+ DrawQ_String_Real(x+scalex*0.25,y+scaley*0.25,string,maxlen,scalex,scaley,shadow,shadow,shadow,alpha*0.8,flags);
+ }
+
+ DrawQ_String_Real(x,y,string,maxlen,scalex,scaley,red,green,blue,alpha,flags);
+}
+
+// color tag printing
+static vec4_t string_colors[] =
+{
+ // Quake3 colors
+ // LordHavoc: why on earth is cyan before magenta in Quake3?
+ // LordHavoc: note: Doom3 uses white for [0] and [7]
+ {0.0, 0.0, 0.0, 1.0}, // black
+ {1.0, 0.0, 0.0, 1.0}, // red
+ {0.0, 1.0, 0.0, 1.0}, // green
+ {1.0, 1.0, 0.0, 1.0}, // yellow
+ {0.0, 0.0, 1.0, 1.0}, // blue
+ {0.0, 1.0, 1.0, 1.0}, // cyan
+ {1.0, 0.0, 1.0, 1.0}, // magenta
+ {1.0, 1.0, 1.0, 1.0}, // white
+ // [515]'s BX_COLOREDTEXT extension
+ {1.0, 1.0, 1.0, 0.5}, // half transparent
+ {0.5, 0.5, 0.5, 1.0} // half brightness
+ // Black's color table
+ //{1.0, 1.0, 1.0, 1.0},
+ //{1.0, 0.0, 0.0, 1.0},
+ //{0.0, 1.0, 0.0, 1.0},
+ //{0.0, 0.0, 1.0, 1.0},
+ //{1.0, 1.0, 0.0, 1.0},
+ //{0.0, 1.0, 1.0, 1.0},
+ //{1.0, 0.0, 1.0, 1.0},
+ //{0.1, 0.1, 0.1, 1.0}
+};
+
+#define STRING_COLORS_COUNT (sizeof(string_colors) / sizeof(vec4_t))
+
+// color is read and changed in the end
+float DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor )
+{
+ vec_t *color;
+ int len;
+ int colorindex;
+ const char *start, *current;
+
+ if( !outcolor || *outcolor == -1 ) {
+ colorindex = STRING_COLOR_DEFAULT;
+ } else {
+ colorindex = *outcolor;
+ }
+ color = string_colors[colorindex];
+
+ if( maxlen < 1)
+ len = (int)strlen( text );
+ else
+ len = min( maxlen, (int) strlen( text ) );
+
+ start = current = text;
+ while( len > 0 ) {
+ // check for color control char
+ if( *current == STRING_COLOR_TAG ) {
+ // get next char
+ current++;
+ len--;
+ if( len == 0 ) {
+ break;