- overbright = v_overbrightbits.integer;
- batch = false;
- batchcount = 0;
- for (pos = 0;pos < r_refdef.drawqueuesize;pos += ((drawqueue_t *)(r_refdef.drawqueue + pos))->size)
- {
- 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 (*str)
- {
- if (strcmp(str, currentpic))
- {
- if (batch)
- {
- batch = false;
- qglEnd();
- }
- currentpic = str;
- pic = Draw_CachePic(str);
- qglBindTexture(GL_TEXTURE_2D, R_GetTexture(pic->tex));
- }
- if (w == 0)
- w = pic->width;
- if (h == 0)
- h = pic->height;
- if (!batch)
- {
- batch = true;
- qglBegin(GL_TRIANGLES);
- batchcount = 0;
- }
- qglTexCoord2f (0, 0);qglVertex2f (x , y );
- qglTexCoord2f (1, 0);qglVertex2f (x+w, y );
- qglTexCoord2f (1, 1);qglVertex2f (x+w, y+h);
- qglTexCoord2f (0, 0);qglVertex2f (x , y );
- qglTexCoord2f (1, 1);qglVertex2f (x+w, y+h);
- qglTexCoord2f (0, 1);qglVertex2f (x , y+h);
- batchcount++;
- }
- else
- {
- if (currentpic[0])
- {
- if (batch)
- {
- batch = false;
- qglEnd();
- }
- currentpic = "";
- qglBindTexture(GL_TEXTURE_2D, 0);
- }
- if (!batch)
- {
- batch = true;
- qglBegin(GL_TRIANGLES);
- batchcount = 0;
- }
- qglTexCoord2f (0, 0);qglVertex2f (x , y );
- qglTexCoord2f (1, 0);qglVertex2f (x+w, y );
- qglTexCoord2f (1, 1);qglVertex2f (x+w, y+h);
- qglTexCoord2f (0, 0);qglVertex2f (x , y );
- qglTexCoord2f (1, 1);qglVertex2f (x+w, y+h);
- qglTexCoord2f (0, 1);qglVertex2f (x , y+h);
- batchcount++;
- }
- break;
- case DRAWQUEUE_STRING:
- str = (char *)(dq + 1);
- if (strcmp("conchars", currentpic))
- {
- if (batch)
- {
- batch = false;
- qglEnd();
- }
- currentpic = "conchars";
- qglBindTexture(GL_TEXTURE_2D, chartexnum);
- }
- if (!batch)
- {
- batch = true;
- qglBegin(GL_TRIANGLES);
- batchcount = 0;
- }
- while ((num = *str++) && x < vid.conwidth)
- {
- if (num != ' ')
- {
- s = (num & 15)*0.0625f + (0.5f / 256.0f);
- t = (num >> 4)*0.0625f + (0.5f / 256.0f);
- u = 0.0625f - (1.0f / 256.0f);
- v = 0.0625f - (1.0f / 256.0f);
- qglTexCoord2f (s , t );qglVertex2f (x , y );
- qglTexCoord2f (s+u, t );qglVertex2f (x+w, y );
- qglTexCoord2f (s+u, t+v);qglVertex2f (x+w, y+h);
- qglTexCoord2f (s , t );qglVertex2f (x , y );
- qglTexCoord2f (s+u, t+v);qglVertex2f (x+w, y+h);
- qglTexCoord2f (s , t+v);qglVertex2f (x , y+h);
- batchcount++;
- }
- x += w;
- }
- break;
- case DRAWQUEUE_MESH:
- if (batch)
- {
- batch = false;
- qglEnd();
- }
-
- mesh = (void *)(dq + 1);
- qglBindTexture(GL_TEXTURE_2D, R_GetTexture(mesh->texture));
- qglVertexPointer(3, GL_FLOAT, sizeof(float[3]), mesh->vertices);CHECKGLERROR
- qglTexCoordPointer(2, GL_FLOAT, sizeof(float[2]), mesh->texcoords);CHECKGLERROR
- qglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(qbyte[4]), mesh->colors);CHECKGLERROR
- qglEnableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
- qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
- qglEnableClientState(GL_COLOR_ARRAY);CHECKGLERROR
- GL_DrawRangeElements(0, mesh->numvertices, mesh->numindices, mesh->indices);
- qglDisableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
- qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
- qglDisableClientState(GL_COLOR_ARRAY);CHECKGLERROR
-
- // restore color, since it got trashed by using color array
- qglColor4ub((qbyte)(((color >> 24) & 0xFF) >> overbright), (qbyte)(((color >> 16) & 0xFF) >> overbright), (qbyte)(((color >> 8) & 0xFF) >> overbright), (qbyte)(color & 0xFF));
- CHECKGLERROR
- currentpic = "\0";
- break;
- }
+ floats[2] = floats[5] = floats[8] = floats[11] = 0;
+ floats[0] = floats[9] = x;
+ floats[1] = floats[4] = y;
+ floats[3] = floats[6] = x + width;
+ floats[7] = floats[10] = y + height;
+
+ R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0);
+}
+
+void DrawQ_Fill(float x, float y, float width, float height, float red, float green, float blue, float alpha, int flags)
+{
+ float floats[12];
+
+ _DrawQ_ProcessDrawFlag(flags);
+ GL_Color(red, green, blue, alpha);
+
+ R_Mesh_VertexPointer(floats, 0, 0);
+ R_Mesh_ColorPointer(NULL, 0, 0);
+ R_Mesh_ResetTextureState();
+
+ floats[2] = floats[5] = floats[8] = floats[11] = 0;
+ floats[0] = floats[9] = x;
+ floats[1] = floats[4] = y;
+ floats[3] = floats[6] = x + width;
+ floats[7] = floats[10] = y + height;
+
+ R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0);
+}
+
+// color tag printing
+static const 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))
+
+static void DrawQ_GetTextColor(float color[4], int colorindex, float r, float g, float b, float a, qboolean shadow)
+{
+ float v = r_textbrightness.value;
+ Vector4Copy(string_colors[colorindex], color);
+ Vector4Set(color, (color[0] * (1-v) + v) * r, (color[1] * (1-v) + v) * g, (color[2] * (1-v) + v) * b, color[3] * a);
+ if (shadow)
+ {
+ float shadowalpha = color[0]+color[1]+color[2] * 0.8;
+ Vector4Set(color, 0, 0, 0, color[3] * bound(0, shadowalpha, 1));