]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_draw.c
UNMERGE! Refactored R_UpdateEntityLighting to CL_UpdateEntityShading, which sets...
[xonotic/darkplaces.git] / gl_draw.c
index 581ef1a22dc8c5fce5df2fab1f86c17e934a08e1..77c873c3e7832ea41b053b65e13ca7922de1edd5 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -45,8 +45,6 @@ cvar_t r_font_antialias = {CVAR_SAVE, "r_font_antialias", "1", "0 = monochrome,
 cvar_t r_nearest_2d = {CVAR_SAVE, "r_nearest_2d", "0", "use nearest filtering on all 2d textures (including conchars)"};
 cvar_t r_nearest_conchars = {CVAR_SAVE, "r_nearest_conchars", "0", "use nearest filtering on conchars texture"};
 
-extern cvar_t v_glslgamma;
-
 //=============================================================================
 /* Support Routines */
 
@@ -446,7 +444,7 @@ reload:
        // show up the right size in the menu even if they were replaced with
        // higher or lower resolution versions
        dpsnprintf(lmpname, sizeof(lmpname), "%s.lmp", pic->name);
-       if (!strncmp(pic->name, "gfx/", 4) && (lmpdata = FS_LoadFile(lmpname, tempmempool, false, &lmpsize)))
+       if ((!strncmp(pic->name, "gfx/", 4) || (gamemode == GAME_BLOODOMNICIDE && !strncmp(pic->name, "locale/", 6))) && (lmpdata = FS_LoadFile(lmpname, tempmempool, false, &lmpsize)))
        {
                if (developer_loading.integer)
                        Con_Printf("loading lump \"%s\"\n", pic->name);
@@ -1018,7 +1016,7 @@ static void gl_draw_start(void)
                        LoadFont(false, va(vabuf, sizeof(vabuf), "gfx/font_%s", dp_fonts.f[i].title), &dp_fonts.f[i], 1, 0);
 
        // draw the loading screen so people have something to see in the newly opened window
-       SCR_UpdateLoadingScreen(true);
+       SCR_UpdateLoadingScreen(true, true);
 }
 
 static void gl_draw_shutdown(void)
@@ -1387,7 +1385,8 @@ float DrawQ_TextWidth_UntilWidth_TrackColors_Scale(const char *text, size_t *max
        else
                width_of = fnt->width_of;
 
-       for (i = 0;((bytes_left = *maxlen - (text - text_start)) > 0) && *text;)
+       i = 0;
+       while (((bytes_left = *maxlen - (text - text_start)) > 0) && *text)
        {
                size_t i0 = i;
                nextch = ch = u8_getnchar(text, &text, bytes_left);
@@ -1616,7 +1615,7 @@ float DrawQ_String_Scale(float startx, float starty, const char *text, size_t ma
                        y += r_textshadow.value * vid.height / vid_conheight.value;
                }
                */
-               for (i = 0;((bytes_left = maxlen - (text - text_start)) > 0) && *text;)
+               while (((bytes_left = maxlen - (text - text_start)) > 0) && *text)
                {
                        nextch = ch = u8_getnchar(text, &text, bytes_left);
                        i = text - text_start;
@@ -1970,8 +1969,6 @@ void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags, qboolean hasalpha)
 
 void DrawQ_LineLoop (drawqueuemesh_t *mesh, int flags)
 {
-       int num;
-
        _DrawQ_SetupAndProcessDrawFlag(flags, NULL, 1);
        if(!r_draw2d.integer && !r_draw2d_force)
                return;
@@ -1983,16 +1980,19 @@ void DrawQ_LineLoop (drawqueuemesh_t *mesh, int flags)
        case RENDERPATH_GL13:
        case RENDERPATH_GL20:
 #ifndef USE_GLES2
-               CHECKGLERROR
-               qglBegin(GL_LINE_LOOP);
-               for (num = 0;num < mesh->num_vertices;num++)
                {
-                       if (mesh->data_color4f)
-                               GL_Color(mesh->data_color4f[num*4+0], mesh->data_color4f[num*4+1], mesh->data_color4f[num*4+2], mesh->data_color4f[num*4+3]);
-                       qglVertex2f(mesh->data_vertex3f[num*3+0], mesh->data_vertex3f[num*3+1]);
+                       int num;
+                       CHECKGLERROR
+                       qglBegin(GL_LINE_LOOP);
+                       for (num = 0;num < mesh->num_vertices;num++)
+                       {
+                               if (mesh->data_color4f)
+                                       GL_Color(mesh->data_color4f[num*4+0], mesh->data_color4f[num*4+1], mesh->data_color4f[num*4+2], mesh->data_color4f[num*4+3]);
+                               qglVertex2f(mesh->data_vertex3f[num*3+0], mesh->data_vertex3f[num*3+1]);
+                       }
+                       qglEnd();
+                       CHECKGLERROR
                }
-               qglEnd();
-               CHECKGLERROR
 #endif
                break;
        case RENDERPATH_D3D9:
@@ -2061,14 +2061,8 @@ void DrawQ_Line (float width, float x1, float y1, float x2, float y2, float r, f
        }
 }
 
-void DrawQ_Lines (float width, int numlines, const float *vertex3f, const float *color4f, int flags)
+void DrawQ_Lines (float width, int numlines, int flags, qboolean hasalpha)
 {
-       int i;
-       qboolean hasalpha = false;
-       for (i = 0;i < numlines*2;i++)
-               if (color4f[i*4+3] < 1.0f)
-                       hasalpha = true;
-
        _DrawQ_SetupAndProcessDrawFlag(flags, NULL, hasalpha ? 0.5f : 1.0f);
 
        if(!r_draw2d.integer && !r_draw2d_force)
@@ -2086,7 +2080,6 @@ void DrawQ_Lines (float width, int numlines, const float *vertex3f, const float
                //qglLineWidth(width);CHECKGLERROR
 
                CHECKGLERROR
-               R_Mesh_PrepareVertices_Generic_Arrays(numlines*2, vertex3f, color4f, NULL);
                qglDrawArrays(GL_LINES, 0, numlines*2);
                CHECKGLERROR
                break;
@@ -2116,10 +2109,10 @@ void DrawQ_SetClipArea(float x, float y, float width, float height)
 
        // We have to convert the con coords into real coords
        // OGL uses top to bottom
-       ix = (int)(0.5 + x * ((float)vid.width / vid_conwidth.integer));
-       iy = (int)(0.5 + y * ((float) vid.height / vid_conheight.integer));
-       iw = (int)(0.5 + (x+width) * ((float)vid.width / vid_conwidth.integer)) - ix;
-       ih = (int)(0.5 + (y+height) * ((float) vid.height / vid_conheight.integer)) - iy;
+       ix = (int)(0.5 + x * ((float)r_refdef.view.width / vid_conwidth.integer)) + r_refdef.view.x;
+       iy = (int)(0.5 + y * ((float)r_refdef.view.height / vid_conheight.integer)) + r_refdef.view.y;
+       iw = (int)(0.5 + width * ((float)r_refdef.view.width / vid_conwidth.integer));
+       ih = (int)(0.5 + height * ((float)r_refdef.view.height / vid_conheight.integer));
        switch(vid.renderpath)
        {
        case RENDERPATH_GL11:
@@ -2161,114 +2154,3 @@ void DrawQ_RecalcView(void)
                r_refdef.draw2dstage = -1; // next draw call will set viewport etc. again
 }
 
-static float blendvertex3f[9] = {-5000, -5000, 10, 10000, -5000, 10, -5000, 10000, 10};
-void R_DrawGamma(void)
-{
-       float c[4];
-       switch(vid.renderpath)
-       {
-       case RENDERPATH_GL20:
-       case RENDERPATH_D3D9:
-       case RENDERPATH_D3D10:
-       case RENDERPATH_D3D11:
-       case RENDERPATH_GLES2:
-               if (vid_usinghwgamma || v_glslgamma.integer)
-                       return;
-               break;
-       case RENDERPATH_GL11:
-       case RENDERPATH_GL13:
-               if (vid_usinghwgamma)
-                       return;
-               break;
-       case RENDERPATH_GLES1:
-       case RENDERPATH_SOFT:
-               return;
-       }
-       // all the blends ignore depth
-//     R_Mesh_ResetTextureState();
-       R_SetupShader_Generic_NoTexture(true, true);
-       GL_DepthMask(true);
-       GL_DepthRange(0, 1);
-       GL_PolygonOffset(0, 0);
-       GL_DepthTest(false);
-
-       // interpretation of brightness and contrast:
-       //   color range := brightness .. (brightness + contrast)
-       // i.e. "c *= contrast; c += brightness"
-       // plausible values for brightness thus range from -contrast to 1
-
-       // apply pre-brightness (subtractive brightness, for where contrast was >= 1)
-       if (vid.support.ext_blend_subtract)
-       {
-               if (v_color_enable.integer)
-               {
-                       c[0] = -v_color_black_r.value / v_color_white_r.value;
-                       c[1] = -v_color_black_g.value / v_color_white_g.value;
-                       c[2] = -v_color_black_b.value / v_color_white_b.value;
-               }
-               else
-                       c[0] = c[1] = c[2] = -v_brightness.value / v_contrast.value;
-               if (c[0] >= 0.01f || c[1] >= 0.01f || c[2] >= 0.01f)
-               {
-                       // need SUBTRACTIVE blending to do this!
-                       GL_BlendEquationSubtract(true);
-                       GL_BlendFunc(GL_ONE, GL_ONE);
-                       GL_Color(c[0], c[1], c[2], 1);
-                       R_Mesh_PrepareVertices_Generic_Arrays(3, blendvertex3f, NULL, NULL);
-                       R_Mesh_Draw(0, 3, 0, 1, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0);
-                       GL_BlendEquationSubtract(false);
-               }
-       }
-
-       // apply contrast
-       if (v_color_enable.integer)
-       {
-               c[0] = v_color_white_r.value;
-               c[1] = v_color_white_g.value;
-               c[2] = v_color_white_b.value;
-       }
-       else
-               c[0] = c[1] = c[2] = v_contrast.value;
-       if (c[0] >= 1.003f || c[1] >= 1.003f || c[2] >= 1.003f)
-       {
-               GL_BlendFunc(GL_DST_COLOR, GL_ONE);
-               while (c[0] >= 1.003f || c[1] >= 1.003f || c[2] >= 1.003f)
-               {
-                       float cc[4];
-                       cc[0] = bound(0, c[0] - 1, 1);
-                       cc[1] = bound(0, c[1] - 1, 1);
-                       cc[2] = bound(0, c[2] - 1, 1);
-                       GL_Color(cc[0], cc[1], cc[2], 1);
-                       R_Mesh_PrepareVertices_Generic_Arrays(3, blendvertex3f, NULL, NULL);
-                       R_Mesh_Draw(0, 3, 0, 1, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0);
-                       c[0] /= 1 + cc[0];
-                       c[1] /= 1 + cc[1];
-                       c[2] /= 1 + cc[2];
-               }
-       }
-       if (c[0] <= 0.997f || c[1] <= 0.997f || c[2] <= 0.997f)
-       {
-               GL_BlendFunc(GL_DST_COLOR, GL_ZERO);
-               GL_Color(c[0], c[1], c[2], 1);
-               R_Mesh_PrepareVertices_Generic_Arrays(3, blendvertex3f, NULL, NULL);
-               R_Mesh_Draw(0, 3, 0, 1, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0);
-       }
-
-       // apply post-brightness (additive brightness, for where contrast was <= 1)
-       if (v_color_enable.integer)
-       {
-               c[0] = v_color_black_r.value;
-               c[1] = v_color_black_g.value;
-               c[2] = v_color_black_b.value;
-       }
-       else
-               c[0] = c[1] = c[2] = v_brightness.value;
-       if (c[0] >= 0.01f || c[1] >= 0.01f || c[2] >= 0.01f)
-       {
-               GL_BlendFunc(GL_ONE, GL_ONE);
-               GL_Color(c[0], c[1], c[2], 1);
-               R_Mesh_PrepareVertices_Generic_Arrays(3, blendvertex3f, NULL, NULL);
-               R_Mesh_Draw(0, 3, 0, 1, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0);
-       }
-}
-