]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_draw.c
adding two new extensions: DP_QC_WHICHPACK (identify a pk3 containing a file), and...
[xonotic/darkplaces.git] / gl_draw.c
index 1d4c50776888833d75848a4e3b9d87845e98d4b3..f6a7532c1cc2ef90323b25e806d970d443cfef62 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -29,7 +29,7 @@ dp_font_t dp_fonts[MAX_FONTS] = {{0}};
 
 cvar_t r_textshadow = {CVAR_SAVE, "r_textshadow", "0", "draws a shadow on all text to improve readability (note: value controls offset, 1 = 1 pixel, 1.5 = 1.5 pixels, etc)"};
 cvar_t r_textbrightness = {CVAR_SAVE, "r_textbrightness", "0", "additional brightness for text color codes (0 keeps colors as is, 1 makes them all white)"};
-cvar_t r_textcontrast = {CVAR_SAVE, "r_textcontrast", "1", "additional contrast for text color codes (1 keeps colors as is, 1 makes them all black)"};
+cvar_t r_textcontrast = {CVAR_SAVE, "r_textcontrast", "1", "additional contrast for text color codes (1 keeps colors as is, 0 makes them all black)"};
 
 extern cvar_t v_glslgamma;
 
@@ -827,7 +827,7 @@ void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, flo
        floats[3] = floats[6] = x + width;
        floats[7] = floats[10] = y + height;
 
-       R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0);
+       R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
 }
 
 void DrawQ_Fill(float x, float y, float width, float height, float red, float green, float blue, float alpha, int flags)
@@ -848,7 +848,7 @@ void DrawQ_Fill(float x, float y, float width, float height, float red, float gr
        floats[3] = floats[6] = x + width;
        floats[7] = floats[10] = y + height;
 
-       R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0);
+       R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
 }
 
 // color tag printing
@@ -948,7 +948,7 @@ float DrawQ_String_Font(float startx, float starty, const char *text, size_t max
 {
        int num, shadow, colorindex = STRING_COLOR_DEFAULT;
        size_t i;
-       float x = startx, y, s, t, u, v;
+       float x = startx, y, s, t, u, v, thisw;
        float *av, *at, *ac;
        float color[4];
        int batchcount;
@@ -956,6 +956,10 @@ float DrawQ_String_Font(float startx, float starty, const char *text, size_t max
        float texcoord2f[QUADELEMENTS_MAXQUADS*4*2];
        float color4f[QUADELEMENTS_MAXQUADS*4*4];
 
+       int tw, th;
+       tw = R_TextureWidth(fnt->tex);
+       th = R_TextureHeight(fnt->tex);
+
        if (maxlen < 1)
                maxlen = 1<<30;
 
@@ -1010,11 +1014,12 @@ float DrawQ_String_Font(float startx, float starty, const char *text, size_t max
                                }
                        }
                        num = (unsigned char) text[i];
+                       thisw = fnt->width_of[num];
                        // FIXME make these smaller to just include the occupied part of the character for slightly faster rendering
-                       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);
+                       s = (num & 15)*0.0625f + (0.5f / tw);
+                       t = (num >> 4)*0.0625f + (0.5f / th);
+                       u = 0.0625f * thisw - (1.0f / tw);
+                       v = 0.0625f - (1.0f / th);
                        ac[ 0] = color[0];ac[ 1] = color[1];ac[ 2] = color[2];ac[ 3] = color[3];
                        ac[ 4] = color[0];ac[ 5] = color[1];ac[ 6] = color[2];ac[ 7] = color[3];
                        ac[ 8] = color[0];ac[ 9] = color[1];ac[10] = color[2];ac[11] = color[3];
@@ -1024,8 +1029,8 @@ float DrawQ_String_Font(float startx, float starty, const char *text, size_t max
                        at[ 4] = s+u;at[ 5] = t+v;
                        at[ 6] = s  ;at[ 7] = t+v;
                        av[ 0] = x  ;av[ 1] = y  ;av[ 2] = 10;
-                       av[ 3] = x+w;av[ 4] = y  ;av[ 5] = 10;
-                       av[ 6] = x+w;av[ 7] = y+h;av[ 8] = 10;
+                       av[ 3] = x+w*thisw;av[ 4] = y  ;av[ 5] = 10;
+                       av[ 6] = x+w*thisw;av[ 7] = y+h;av[ 8] = 10;
                        av[ 9] = x  ;av[10] = y+h;av[11] = 10;
                        ac += 16;
                        at += 8;
@@ -1034,20 +1039,20 @@ float DrawQ_String_Font(float startx, float starty, const char *text, size_t max
                        if (batchcount >= QUADELEMENTS_MAXQUADS)
                        {
                                GL_LockArrays(0, batchcount * 4);
-                               R_Mesh_Draw(0, batchcount * 4, batchcount * 2, quadelements, 0, 0);
+                               R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, NULL, quadelements, 0, 0);
                                GL_LockArrays(0, 0);
                                batchcount = 0;
                                ac = color4f;
                                at = texcoord2f;
                                av = vertex3f;
                        }
-                       x += fnt->width_of[num] * w;
+                       x += thisw * w;
                }
        }
        if (batchcount > 0)
        {
                GL_LockArrays(0, batchcount * 4);
-               R_Mesh_Draw(0, batchcount * 4, batchcount * 2, quadelements, 0, 0);
+               R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, NULL, quadelements, 0, 0);
                GL_LockArrays(0, 0);
        }
 
@@ -1146,7 +1151,7 @@ void DrawQ_SuperPic(float x, float y, cachepic_t *pic, float width, float height
        floats[28] = r4;floats[29] = g4;floats[30] = b4;floats[31] = a4;
        floats[32] = r3;floats[33] = g3;floats[34] = b3;floats[35] = a3;
 
-       R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0);
+       R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
 }
 
 void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags)
@@ -1161,7 +1166,7 @@ void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags)
        R_SetupGenericShader(mesh->texture != NULL);
 
        GL_LockArrays(0, mesh->num_vertices);
-       R_Mesh_Draw(0, mesh->num_vertices, mesh->num_triangles, mesh->data_element3i, 0, 0);
+       R_Mesh_Draw(0, mesh->num_vertices, 0, mesh->num_triangles, NULL, mesh->data_element3s, 0, 0);
        GL_LockArrays(0, 0);
 }
 
@@ -1189,6 +1194,8 @@ void DrawQ_Line (float width, float x1, float y1, float x2, float y2, float r, f
 {
        _DrawQ_ProcessDrawFlag(flags);
 
+       R_SetupGenericShader(false);
+
        CHECKGLERROR
        qglLineWidth(width);CHECKGLERROR
 
@@ -1252,7 +1259,7 @@ void R_DrawGamma(void)
                        while (c[0] >= 1.01f || c[1] >= 1.01f || c[2] >= 1.01f)
                        {
                                GL_Color(bound(0, c[0] - 1, 1), bound(0, c[1] - 1, 1), bound(0, c[2] - 1, 1), 1);
-                               R_Mesh_Draw(0, 3, 1, polygonelements, 0, 0);
+                               R_Mesh_Draw(0, 3, 0, 1, NULL, polygonelements, 0, 0);
                                VectorScale(c, 0.5, c);
                        }
                }
@@ -1268,7 +1275,7 @@ void R_DrawGamma(void)
                {
                        GL_BlendFunc(GL_ONE, GL_ONE);
                        GL_Color(c[0], c[1], c[2], 1);
-                       R_Mesh_Draw(0, 3, 1, polygonelements, 0, 0);
+                       R_Mesh_Draw(0, 3, 0, 1, NULL, polygonelements, 0, 0);
                }
        }
 }