]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_draw.c
do q1bsp lighting checks starting with + 0.125 unit Z offset to improve chances of...
[xonotic/darkplaces.git] / gl_draw.c
index 1d448aca4f1701ceea4890d8450bcbe521659d9d..38c6536585b3c00d716f06686425cad2df070cf8 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "cl_video.h"
 
-cvar_t r_textshadow = {0, "r_textshadow", "0" "draws a shadow on all text to improve readability"};
+cvar_t r_textshadow = {0, "r_textshadow", "0", "draws a shadow on all text to improve readability"};
 
 static rtexture_t *char_texture;
 cachepic_t *r_crosshairs[NUMCROSSHAIRS+1];
@@ -502,9 +502,10 @@ void DrawQ_Begin(void)
        r_view_matrix = r_refdef.viewentitymatrix;
        GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
 
-       qglViewport(r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);
+       CHECKGLERROR
+       qglViewport(r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);CHECKGLERROR
        GL_SetupView_Mode_Ortho(0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100);
-       qglDepthFunc(GL_LEQUAL);
+       qglDepthFunc(GL_LEQUAL);CHECKGLERROR
        R_Mesh_Matrix(&identitymatrix);
 
        GL_DepthMask(true);
@@ -514,6 +515,19 @@ void DrawQ_Begin(void)
        r_refdef.draw2dstage = true;
 }
 
+static void _DrawQ_ProcessDrawFlag(int flags)
+{
+       CHECKGLERROR
+       if(flags == DRAWFLAG_ADDITIVE)
+               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
+       else if(flags == DRAWFLAG_MODULATE)
+               GL_BlendFunc(GL_DST_COLOR, GL_ZERO);
+       else if(flags == DRAWFLAG_2XMODULATE)
+               GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR);
+       else
+               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+}
+
 void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, float red, float green, float blue, float alpha, int flags)
 {
        if (!r_refdef.draw2dstage)
@@ -544,14 +558,7 @@ void DrawQ_String_Real(float x, float y, const char *string, int maxlen, float w
        if (alpha < (1.0f / 255.0f))
                return;
 
-       if(flags == DRAWFLAG_ADDITIVE)
-               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
-       else if(flags == DRAWFLAG_MODULATE)
-               GL_BlendFunc(GL_DST_COLOR, GL_ZERO);
-       else if(flags == DRAWFLAG_2XMODULATE)
-               GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR);
-       else
-               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       _DrawQ_ProcessDrawFlag(flags);
 
        GL_Color(red, green, blue, alpha);
 
@@ -745,14 +752,7 @@ void DrawQ_SuperPic(float x, float y, cachepic_t *pic, float width, float height
        if (!r_render.integer)
                return;
 
-       if(flags == DRAWFLAG_ADDITIVE)
-               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
-       else if(flags == DRAWFLAG_MODULATE)
-               GL_BlendFunc(GL_DST_COLOR, GL_ZERO);
-       else if(flags == DRAWFLAG_2XMODULATE)
-               GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR);
-       else
-               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       _DrawQ_ProcessDrawFlag(flags);
 
        R_Mesh_VertexPointer(floats);
        R_Mesh_ColorPointer(floats + 20);
@@ -795,14 +795,7 @@ void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags)
        if (!r_render.integer)
                return;
 
-       if(flags == DRAWFLAG_ADDITIVE)
-               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
-       else if(flags == DRAWFLAG_MODULATE)
-               GL_BlendFunc(GL_DST_COLOR, GL_ZERO);
-       else if(flags == DRAWFLAG_2XMODULATE)
-               GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR);
-       else
-               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       _DrawQ_ProcessDrawFlag(flags);
 
        R_Mesh_VertexPointer(mesh->data_vertex3f);
        R_Mesh_ColorPointer(mesh->data_color4f);
@@ -828,16 +821,10 @@ void DrawQ_LineLoop (drawqueuemesh_t *mesh, int flags)
        if (!r_render.integer)
                return;
 
-       if(flags == DRAWFLAG_ADDITIVE)
-               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
-       else if(flags == DRAWFLAG_MODULATE)
-               GL_BlendFunc(GL_DST_COLOR, GL_ZERO);
-       else if(flags == DRAWFLAG_2XMODULATE)
-               GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR);
-       else
-               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       _DrawQ_ProcessDrawFlag(flags);
 
        GL_Color(1,1,1,1);
+       CHECKGLERROR
        qglBegin(GL_LINE_LOOP);
        for (num = 0;num < mesh->num_vertices;num++)
        {
@@ -846,6 +833,7 @@ void DrawQ_LineLoop (drawqueuemesh_t *mesh, int flags)
                qglVertex2f(mesh->data_vertex3f[num*3+0], mesh->data_vertex3f[num*3+1]);
        }
        qglEnd();
+       CHECKGLERROR
 }
 
 //LordHavoc: FIXME: this is nasty!
@@ -856,7 +844,8 @@ void DrawQ_LineWidth (float width)
                Con_Printf("DrawQ_LineWidth: not in 2d rendering stage!\n");
                return;
        }
-       qglLineWidth(width);
+       CHECKGLERROR
+       qglLineWidth(width);CHECKGLERROR
 }
 
 //[515]: this is old, delete
@@ -871,23 +860,19 @@ void DrawQ_Line (float width, float x1, float y1, float x2, float y2, float r, f
        if (!r_render.integer)
                return;
 
+       CHECKGLERROR
        if(width > 0)
                DrawQ_LineWidth(width);
 
-       if(flags == DRAWFLAG_ADDITIVE)
-               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
-       else if(flags == DRAWFLAG_MODULATE)
-               GL_BlendFunc(GL_DST_COLOR, GL_ZERO);
-       else if(flags == DRAWFLAG_2XMODULATE)
-               GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR);
-       else
-               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       _DrawQ_ProcessDrawFlag(flags);
 
        GL_Color(r,g,b,alpha);
+       CHECKGLERROR
        qglBegin(GL_LINES);
        qglVertex2f(x1, y1);
        qglVertex2f(x2, y2);
        qglEnd();
+       CHECKGLERROR
 }
 
 void DrawQ_SetClipArea(float x, float y, float width, float height)