]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_draw.c
console parsing now behaves like qwcl, thanks to Fuh for pointing out the problems...
[xonotic/darkplaces.git] / gl_draw.c
index 4ef340daa4f4c158ceae67b2f5292a8d69c5e986..7ba2282e38eb8bc0eff765055c6a3e6abd87ff38 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -328,7 +328,7 @@ void Draw_FreePic(char *picname)
        hashkey = ((crc >> 8) ^ crc) % CACHEPICHASHSIZE;
        for (pic = cachepichash[hashkey];pic;pic = pic->chain)
        {
-               if (!strcmp (picname, pic->name))
+               if (!strcmp (picname, pic->name) && pic->tex)
                {
                        R_FreeTexture(pic->tex);
                        pic->width = 0;
@@ -378,7 +378,7 @@ float blendvertex3f[9] = {-5000, -5000, 10, 10000, -5000, 10, -5000, 10000, 10};
 int quadelements[768];
 void R_DrawQueue(void)
 {
-       int pos, num, chartexnum, overbright, texnum, batch;
+       int pos, num, chartexnum, texnum, batch;
        float x, y, w, h, s, t, u, v, *av, *at, c[4];
        cachepic_t *pic;
        drawqueue_t *dq;
@@ -421,7 +421,6 @@ void R_DrawQueue(void)
        texnum = 0;
        color = 0;
 
-       overbright = v_overbrightbits.integer;
        batch = false;
        batchcount = 0;
        for (pos = 0;pos < r_refdef.drawqueuesize;pos += ((drawqueue_t *)(r_refdef.drawqueue + pos))->size)
@@ -429,19 +428,21 @@ void R_DrawQueue(void)
                dq = (drawqueue_t *)(r_refdef.drawqueue + pos);
                color = dq->color;
                
-               if(dq->flags & DRAWFLAG_ADDITIVE)
+               if(dq->flags == DRAWFLAG_ADDITIVE)
                        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
-               else if(dq->flags & DRAWFLAG_MODULATE)
+               else if(dq->flags == DRAWFLAG_MODULATE)
                        GL_BlendFunc(GL_DST_COLOR, GL_ZERO);
+               else if(dq->flags == DRAWFLAG_2XMODULATE)
+                       GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR);
                else
                        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-               
+
                GL_DepthMask(true);
                GL_DepthTest(false);
 
-               c[0] = (float) ((color >> 24) & 0xFF) * (1.0f / 255.0f) * r_colorscale;
-               c[1] = (float) ((color >> 16) & 0xFF) * (1.0f / 255.0f) * r_colorscale;
-               c[2] = (float) ((color >>  8) & 0xFF) * (1.0f / 255.0f) * r_colorscale;
+               c[0] = (float) ((color >> 24) & 0xFF) * (1.0f / 255.0f);
+               c[1] = (float) ((color >> 16) & 0xFF) * (1.0f / 255.0f);
+               c[2] = (float) ((color >>  8) & 0xFF) * (1.0f / 255.0f);
                c[3] = (float) ( color        & 0xFF) * (1.0f / 255.0f);
                x = dq->x;
                y = dq->y;
@@ -498,14 +499,32 @@ void R_DrawQueue(void)
                        break;
                case DRAWQUEUE_MESH:
                        mesh = (void *)(dq + 1);
-                       GL_VertexPointer(mesh->vertex3f);
-                       GL_ColorPointer(mesh->color4f);
+                       GL_VertexPointer(mesh->data_vertex3f);
+                       GL_ColorPointer(mesh->data_color4f);
                        m.tex[0] = R_GetTexture(mesh->texture);
-                       m.pointer_texcoord[0] = mesh->texcoord2f;
+                       m.pointer_texcoord[0] = mesh->data_texcoord2f;
                        R_Mesh_State_Texture(&m);
-                       R_Mesh_Draw(mesh->numvertices, mesh->numtriangles, mesh->element3i);
+                       R_Mesh_Draw(mesh->num_vertices, mesh->num_triangles, mesh->data_element3i);
                        currentpic = "\0";
                        break;
+               case DRAWQUEUE_SETCLIP:
+                       {
+                               // We have to convert the con coords into real coords
+                               int x , y, width, height;
+                               x = dq->x * ((float)vid.realwidth / vid.conwidth);
+                               // OGL uses top to bottom 
+                               y = dq->y * ((float) vid.realheight / vid.conheight);
+                               width = dq->scalex * ((float)vid.realwidth / vid.conwidth);
+                               height = dq->scaley * ((float)vid.realheight / vid.conheight);
+
+                               GL_Scissor(x, y, width, height);
+
+                               GL_ScissorTest(true);
+                       }
+                       break;
+               case DRAWQUEUE_RESETCLIP:
+                       GL_ScissorTest(false);
+                       break;                          
                }
        }
 
@@ -524,7 +543,6 @@ void R_DrawQueue(void)
                }
                else
                        c[0] = c[1] = c[2] = v_contrast.value;
-               VectorScale(c, (float) (1 << v_overbrightbits.integer), c);
                if (c[0] >= 1.01f || c[1] >= 1.01f || c[2] >= 1.01f)
                {
                        GL_BlendFunc(GL_DST_COLOR, GL_ONE);