]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_draw.c
no longer uses glColor3f at all
[xonotic/darkplaces.git] / gl_draw.c
index 959e712d70558da646372ddf020e8012a45824b7..330b13e9e2053aef32b7d5c9fd6d1546724bf245 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -37,7 +37,7 @@ static int numcachepics;
 
 static rtexturepool_t *drawtexturepool;
 
-static byte pointerimage[256] =
+static qbyte pointerimage[256] =
 {
        "333333332......."
        "26777761........"
@@ -60,7 +60,7 @@ static byte pointerimage[256] =
 static rtexture_t *draw_generatemousepointer(void)
 {
        int i;
-       byte buffer[256][4];
+       qbyte buffer[256][4];
        for (i = 0;i < 256;i++)
        {
                if (pointerimage[i] == '.')
@@ -84,7 +84,7 @@ static rtexture_t *draw_generatemousepointer(void)
 // must match NUMCROSSHAIRS in r_crosshairs.c
 #define NUMCROSSHAIRS 5
 
-static byte *crosshairtexdata[NUMCROSSHAIRS] =
+static qbyte *crosshairtexdata[NUMCROSSHAIRS] =
 {
        "................"
        "................"
@@ -176,7 +176,7 @@ static rtexture_t *draw_generatecrosshair(int num)
 {
        int i;
        char *in;
-       byte data[16*16][4];
+       qbyte data[16*16][4];
        in = crosshairtexdata[num];
        for (i = 0;i < 16*16;i++)
        {
@@ -192,7 +192,7 @@ static rtexture_t *draw_generatecrosshair(int num)
                        data[i][0] = 255;
                        data[i][1] = 255;
                        data[i][2] = 255;
-                       data[i][3] = (byte) ((int) (in[i] - '0') * 255 / 7);
+                       data[i][3] = (qbyte) ((int) (in[i] - '0') * 255 / 7);
                }
        }
        return R_LoadTexture(drawtexturepool, va("crosshair%i", num), 16, 16, &data[0][0], TEXTYPE_RGBA, TEXF_ALPHA | TEXF_PRECACHE);
@@ -233,9 +233,9 @@ cachepic_t  *Draw_CachePic (char *path)
        {
                if (!strcmp(path, "conchars"))
                {
-                       byte *pix;
+                       qbyte *pix;
                        // conchars is a raw image and with the wrong transparent color
-                       pix = (byte *)p;
+                       pix = (qbyte *)p;
                        for (i = 0;i < 128 * 128;i++)
                                if (pix[i] == 0)
                                        pix[i] = 255;
@@ -391,7 +391,7 @@ void R_DrawQueue(void)
                if (color != dq->color)
                {
                        color = dq->color;
-                       glColor4ub((byte)((color >> 24) & 0xFF) >> overbright, (byte)((color >> 16) & 0xFF) >> overbright, (byte)((color >> 8) & 0xFF) >> overbright, (byte)(color & 0xFF));
+                       glColor4ub((qbyte)(((color >> 24) & 0xFF) >> overbright), (qbyte)(((color >> 16) & 0xFF) >> overbright), (qbyte)(((color >> 8) & 0xFF) >> overbright), (qbyte)(color & 0xFF));
                }
                x = dq->x;
                y = dq->y;
@@ -505,10 +505,10 @@ void R_DrawQueue(void)
                        glBegin (GL_TRIANGLES);
                        while (t >= 1.01f)
                        {
-                               if (t >= 2)
-                                       glColor3f (1, 1, 1);
-                               else
-                                       glColor3f (t-1, t-1, t-1);
+                               num = (int) ((t - 1.0f) * 255.0f);
+                               if (num > 255)
+                                       num = 255;
+                               glColor4ub ((qbyte) num, (qbyte) num, (qbyte) num, 255);
                                glVertex2f (-5000, -5000);
                                glVertex2f (10000, -5000);
                                glVertex2f (-5000, 10000);
@@ -522,10 +522,11 @@ void R_DrawQueue(void)
                        glBlendFunc(GL_ZERO, GL_SRC_COLOR);
                        CHECKGLERROR
                        glBegin(GL_TRIANGLES);
-                       glColor3f(t, t, t);
-                       glVertex2f(-5000, -5000);
-                       glVertex2f(10000, -5000);
-                       glVertex2f(-5000, 10000);
+                       num = (int) (t * 255.0f);
+                       glColor4ub ((qbyte) num, (qbyte) num, (qbyte) num, 255);
+                       glVertex2f (-5000, -5000);
+                       glVertex2f (10000, -5000);
+                       glVertex2f (-5000, 10000);
                        glEnd();
                        CHECKGLERROR
                }
@@ -533,7 +534,8 @@ void R_DrawQueue(void)
                {
                        glBlendFunc (GL_ONE, GL_ONE);
                        CHECKGLERROR
-                       glColor3f (v_brightness.value, v_brightness.value, v_brightness.value);
+                       num = (int) (v_brightness.value * 255.0f);
+                       glColor4ub ((qbyte) num, (qbyte) num, (qbyte) num, 255);
                        CHECKGLERROR
                        glBegin (GL_TRIANGLES);
                        glVertex2f (-5000, -5000);
@@ -552,8 +554,8 @@ void R_DrawQueue(void)
        CHECKGLERROR
        glEnable (GL_DEPTH_TEST);
        CHECKGLERROR
-       glDisable(GL_BLEND);
+       glDisable (GL_BLEND);
        CHECKGLERROR
-       glColor3f(1,1,1);
+       glColor4ub (255, 255, 255, 255);
        CHECKGLERROR
 }