]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_draw.c
prevent abuse by ending netname with a ^: if the name is not a valid colored string...
[xonotic/darkplaces.git] / gl_draw.c
index 11186d0f71658d39d548ee408f4ce82bca166199..2f9d94a4513e2cf785df566344919824a31a2070 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -577,7 +577,55 @@ static void _DrawQ_ProcessDrawFlag(int flags)
 
 void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, float red, float green, float blue, float alpha, int flags)
 {
-       DrawQ_SuperPic(x,y,pic,width,height,0,0,red,green,blue,alpha,1,0,red,green,blue,alpha,0,1,red,green,blue,alpha,1,1,red,green,blue,alpha,flags);
+       float floats[20];
+
+       _DrawQ_ProcessDrawFlag(flags);
+       GL_Color(red, green, blue, alpha);
+
+       R_Mesh_VertexPointer(floats, 0, 0);
+       R_Mesh_ColorPointer(NULL, 0, 0);
+       R_Mesh_ResetTextureState();
+       if (pic)
+       {
+               if (width == 0)
+                       width = pic->width;
+               if (height == 0)
+                       height = pic->height;
+               R_Mesh_TexBind(0, R_GetTexture(pic->tex));
+               R_Mesh_TexCoordPointer(0, 2, floats + 12, 0, 0);
+               floats[12] = 0;floats[13] = 0;
+               floats[14] = 1;floats[15] = 0;
+               floats[16] = 1;floats[17] = 1;
+               floats[18] = 0;floats[19] = 1;
+       }
+
+       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
@@ -624,7 +672,7 @@ static void DrawQ_GetTextColor(float color[4], int colorindex, float r, float g,
 float DrawQ_String(float startx, float starty, const char *text, int maxlen, float w, float h, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor, qboolean ignorecolorcodes)
 {
        int i, num, shadow, colorindex;
-       float x, y, s, t, u, v;
+       float x = startx, y, s, t, u, v;
        float *av, *at, *ac;
        float color[4];
        int batchcount;
@@ -663,26 +711,28 @@ float DrawQ_String(float startx, float starty, const char *text, int maxlen, flo
                        x += r_textshadow.value;
                        y += r_textshadow.value;
                }
-               // because this loop increments x before it draws, we must bias x first
-               x -= w;
-               for (i = 0;i < maxlen && text[i];)
+               for (i = 0;i < maxlen && text[i];i++, x += w)
                {
+                       if (text[i] == ' ')
+                               continue;
                        if (text[i] == STRING_COLOR_TAG && !ignorecolorcodes && i + 1 < maxlen)
                        {
                                if (text[i+1] == STRING_COLOR_TAG)
+                               {
                                        i++;
+                                       if (text[i] == ' ')
+                                               continue;
+                               }
                                else if (text[i+1] >= '0' && text[i+1] <= '9')
                                {
                                        colorindex = text[i+1] - '0';
                                        DrawQ_GetTextColor(color, colorindex, basered, basegreen, baseblue, basealpha, shadow);
-                                       i += 2;
+                                       i++;
+                                       x -= w;
                                        continue;
                                }
                        }
-                       num = text[i++];
-                       x += w;
-                       if (num == ' ')
-                               continue;
+                       num = text[i];
                        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);