]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_draw.c
cleaned up qw-related todo items and added some newly discovered qw issues
[xonotic/darkplaces.git] / gl_draw.c
index 82b2bea79bff4c3cbb601c7476a9510b5ae7ac98..000a391dea8a42c0e237f8f6c15a6d35489eb23b 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -341,11 +341,11 @@ cachepic_t        *Draw_CachePic (const char *path, qboolean persistent)
                flags |= TEXF_CLAMP;
 
        // load a high quality image from disk if possible
-       pic->tex = loadtextureimage(drawtexturepool, path, 0, 0, false, flags);
+       pic->tex = loadtextureimage(drawtexturepool, path, 0, 0, false, flags | (gl_texturecompression_2d.integer ? TEXF_COMPRESS : 0));
        if (pic->tex == NULL && !strncmp(path, "gfx/", 4))
        {
                // compatibility with older versions which did not require gfx/ prefix
-               pic->tex = loadtextureimage(drawtexturepool, path + 4, 0, 0, false, flags);
+               pic->tex = loadtextureimage(drawtexturepool, path + 4, 0, 0, false, flags | (gl_texturecompression_2d.integer ? TEXF_COMPRESS : 0));
        }
        // if a high quality image was loaded, set the pic's size to match it, just
        // in case there's no low quality version to get the size from
@@ -550,6 +550,7 @@ static void _DrawQ_Setup(void)
 
        GL_DepthMask(true);
        GL_DepthRange(0, 1);
+       GL_PolygonOffset(0, 0);
        GL_DepthTest(false);
        GL_Color(1,1,1,1);
        GL_AlphaTest(false);
@@ -671,8 +672,8 @@ 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;
+       int i, num, shadow, colorindex = STRING_COLOR_DEFAULT;
+       float x = startx, y, s, t, u, v;
        float *av, *at, *ac;
        float color[4];
        int batchcount;
@@ -711,26 +712,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);
@@ -775,6 +778,10 @@ float DrawQ_String(float startx, float starty, const char *text, int maxlen, flo
                        GL_LockArrays(0, 0);
                }
        }
+
+       if (outcolor)
+               *outcolor = colorindex;
+
        // note: this relies on the proper text (not shadow) being drawn last
        return x;
 }
@@ -939,6 +946,7 @@ void R_DrawGamma(void)
                R_Mesh_ResetTextureState();
                GL_DepthMask(true);
                GL_DepthRange(0, 1);
+               GL_PolygonOffset(0, 0);
                GL_DepthTest(false);
                if (v_color_enable.integer)
                {