]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - r_lightning.c
implemented support for GL_ARB_texture_compression - this is controlled
[xonotic/darkplaces.git] / r_lightning.c
index eabf768f2f6cc56e9a3cf235d094868d1a09748f..c8ff41f4eb8107dab90ba66459505ef257d23106 100644 (file)
@@ -216,13 +216,13 @@ void R_CalcLightningBeamPolygonTexCoord2f(float *tc, float t1, float t2)
 void R_FogLightningBeam_Vertex3f_Color4f(const float *v, float *c, int numverts, float r, float g, float b, float a)
 {
        int i;
-       float ifog;
+       float fog;
        for (i = 0;i < numverts;i++, v += 3, c += 4)
        {
-               ifog = 1 - VERTEXFOGTABLE(VectorDistance(v, r_view.origin));
-               c[0] = r * ifog;
-               c[1] = g * ifog;
-               c[2] = b * ifog;
+               fog = FogPoint_World(v);
+               c[0] = r * fog;
+               c[1] = g * fog;
+               c[2] = b * fog;
                c[3] = a;
        }
 }
@@ -239,24 +239,27 @@ void R_DrawLightningBeam_TransparentCallback(const entity_render_t *ent, const r
        R_Mesh_Matrix(&identitymatrix);
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
        GL_DepthMask(false);
+       GL_DepthRange(0, 1);
+       GL_PolygonOffset(r_refdef.polygonfactor, r_refdef.polygonoffset);
        GL_DepthTest(true);
        if (r_lightningbeam_qmbtexture.integer && r_lightningbeamqmbtexture == NULL)
                r_lightningbeams_setupqmbtexture();
        if (!r_lightningbeam_qmbtexture.integer && r_lightningbeamtexture == NULL)
                r_lightningbeams_setuptexture();
 
-       R_Mesh_VertexPointer(vertex3f);
+       R_Mesh_VertexPointer(vertex3f, 0, 0);
+       // FIXME: fixed function path can't properly handle r_view.colorscale > 1
        if (r_refdef.fogenabled)
        {
                // per vertex colors if fog is used
-               R_Mesh_ColorPointer(color4f);
-               R_FogLightningBeam_Vertex3f_Color4f(vertex3f, color4f, 12, r_lightningbeam_color_red.value, r_lightningbeam_color_green.value, r_lightningbeam_color_blue.value, 1);
+               R_Mesh_ColorPointer(color4f, 0, 0);
+               R_FogLightningBeam_Vertex3f_Color4f(vertex3f, color4f, 12, r_lightningbeam_color_red.value * r_view.colorscale, r_lightningbeam_color_green.value * r_view.colorscale, r_lightningbeam_color_blue.value * r_view.colorscale, 1);
        }
        else
        {
                // solid color if fog is not used
-               R_Mesh_ColorPointer(NULL);
-               GL_Color(r_lightningbeam_color_red.value, r_lightningbeam_color_green.value, r_lightningbeam_color_blue.value, 1);
+               R_Mesh_ColorPointer(NULL, 0, 0);
+               GL_Color(r_lightningbeam_color_red.value * r_view.colorscale, r_lightningbeam_color_green.value * r_view.colorscale, r_lightningbeam_color_blue.value * r_view.colorscale, 1);
        }
        memset(&m, 0, sizeof(m));
        if (r_lightningbeam_qmbtexture.integer)
@@ -271,7 +274,7 @@ void R_DrawLightningBeam_TransparentCallback(const entity_render_t *ent, const r
                const beam_t *b = cl.beams + surfacelist[surfacelistindex];
                vec3_t beamdir, right, up, offset, start, end;
                float length, t1, t2;
-               
+
                CL_Beam_CalculatePositions(b, start, end);
 
                // calculate beam direction (beamdir) vector and beam length
@@ -335,7 +338,7 @@ void R_DrawLightningBeam_TransparentCallback(const entity_render_t *ent, const r
 
                // draw the 3 polygons as one batch of 6 triangles using the 12 vertices
                GL_LockArrays(0, 12);
-               R_Mesh_Draw(0, 12, 6, r_lightningbeamelements);
+               R_Mesh_Draw(0, 12, 6, r_lightningbeamelements, 0, 0);
                GL_LockArrays(0, 0);
        }
 }