]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rsurf.c
darkplaces now compiles in mingw
[xonotic/darkplaces.git] / gl_rsurf.c
index d1d45ab6a8511fc3ea830d48361154555a1a26d9..494a93a58d2b4e2649b7058daded46c23fb57f3c 100644 (file)
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 static signed int blocklights[MAX_LIGHTMAP_SIZE*MAX_LIGHTMAP_SIZE*3]; // LordHavoc: *3 for colored lighting
 
-static byte templight[MAX_LIGHTMAP_SIZE*MAX_LIGHTMAP_SIZE*4];
+static qbyte templight[MAX_LIGHTMAP_SIZE*MAX_LIGHTMAP_SIZE*4];
 
 cvar_t r_ambient = {0, "r_ambient", "0"};
 cvar_t r_vertexsurfaces = {0, "r_vertexsurfaces", "0"};
@@ -50,12 +50,9 @@ static int dlightdivtable[32768];
 void GL_Surf_Init(void)
 {
        int i;
-       if (!dlightdivtable[1])
-       {
-               dlightdivtable[0] = 4194304;
-               for (i = 1;i < 32768;i++)
-                       dlightdivtable[i] = 4194304 / (i << 7);
-       }
+       dlightdivtable[0] = 4194304;
+       for (i = 1;i < 32768;i++)
+               dlightdivtable[i] = 4194304 / (i << 7);
 
        Cvar_RegisterVariable(&r_ambient);
        Cvar_RegisterVariable(&r_vertexsurfaces);
@@ -171,7 +168,7 @@ void R_StainNode (mnode_t *node, model_t *model, vec3_t origin, float radius, in
        float ndist;
        msurface_t *surf, *endsurf;
        int sdtable[256], td, maxdist, maxdist2, maxdist3, i, s, t, smax, tmax, smax3, dist2, impacts, impactt, subtract, a, stained, cr, cg, cb, ca, ratio;
-       byte *bl;
+       qbyte *bl;
        vec3_t impact;
        // LordHavoc: use 64bit integer...  shame it's not very standardized...
 #if _MSC_VER || __BORLANDC__
@@ -265,9 +262,9 @@ loc0:
                                                                                cr = (((icolor[4] - icolor[0]) * ratio) >> 8) + icolor[0];
                                                                                cg = (((icolor[5] - icolor[1]) * ratio) >> 8) + icolor[1];
                                                                                cb = (((icolor[6] - icolor[2]) * ratio) >> 8) + icolor[2];
-                                                                               bl[0] = (byte) ((((cr - (int) bl[0]) * a) >> 8) + (int) bl[0]);
-                                                                               bl[1] = (byte) ((((cg - (int) bl[1]) * a) >> 8) + (int) bl[1]);
-                                                                               bl[2] = (byte) ((((cb - (int) bl[2]) * a) >> 8) + (int) bl[2]);
+                                                                               bl[0] = (qbyte) ((((cr - (int) bl[0]) * a) >> 8) + (int) bl[0]);
+                                                                               bl[1] = (qbyte) ((((cg - (int) bl[1]) * a) >> 8) + (int) bl[1]);
+                                                                               bl[2] = (qbyte) ((((cb - (int) bl[2]) * a) >> 8) + (int) bl[2]);
                                                                                stained = true;
                                                                        }
                                                                }
@@ -352,8 +349,8 @@ Combine and scale multiple lightmaps into the 8.8 format in blocklights
 */
 static void R_BuildLightMap (msurface_t *surf, int dlightchanged)
 {
-       int             smax, tmax, i, j, size, size3, shift, scale, maps, *bl, stride, l;
-       byte    *lightmap, *out, *stain;
+       int smax, tmax, i, j, size, size3, shift, scale, maps, *bl, stride, l;
+       qbyte *lightmap, *out, *stain;
 
        // update cached lighting info
        surf->cached_dlight = 0;
@@ -562,10 +559,7 @@ static int RSurfShader_Sky(int stage, msurface_t *s)
                        m.cg = 1;
                        m.cb = 1;
                        m.ca = 1;
-                       if (r_mergesky.integer)
-                               m.tex[0] = R_GetTexture(mergeskytexture);
-                       else
-                               m.tex[0] = R_GetTexture(solidskytexture);
+                       m.tex[0] = R_GetTexture(solidskytexture);
                        m.texcoords[0] = &svert[0].st[0];
                        m.texcoordstep[0] = sizeof(surfvert_t);
                        speedscale = cl.time * (8.0/128.0);
@@ -622,7 +616,7 @@ static int RSurfShader_Sky(int stage, msurface_t *s)
        }
        else if (stage == 1)
        {
-               if (skyrenderglquake && !r_mergesky.integer)
+               if (skyrenderglquake)
                {
                        memset(&m, 0, sizeof(m));
                        m.transparent = false;
@@ -926,13 +920,7 @@ static void RSurfShader_Wall_Pass_BaseMTex(msurface_t *s)
        m.numtriangles = s->mesh.numtriangles;
        m.numverts = s->mesh.numverts;
        m.index = s->mesh.index;
-       m.cr = 1;
-       if (lighthalf)
-               m.cr *= 2;
-       if (gl_combine.integer)
-               m.cr *= 4;
-       m.cg = m.cr;
-       m.cb = m.cr;
+       m.cr = m.cg = m.cb = (float) (1 << lightscalebit);
        m.ca = currentrenderentity->alpha;
        m.tex[0] = R_GetTexture(s->currenttexture->texture);
        m.tex[1] = R_GetTexture(s->lightmaptexture);
@@ -1006,18 +994,7 @@ static void RSurfShader_Wall_Pass_BaseTexture(msurface_t *s)
        m.numtriangles = s->mesh.numtriangles;
        m.numverts = s->mesh.numverts;
        m.index = s->mesh.index;
-       if (lighthalf)
-       {
-               m.cr = 2;
-               m.cg = 2;
-               m.cb = 2;
-       }
-       else
-       {
-               m.cr = 1;
-               m.cg = 1;
-               m.cb = 1;
-       }
+       m.cr = m.cg = m.cb = (float) (1 << v_overbrightbits.integer);
        m.ca = 1;
        m.tex[0] = R_GetTexture(s->currenttexture->texture);
        m.texcoords[0] = &s->mesh.vertex->st[0];
@@ -1052,11 +1029,7 @@ static void RSurfShader_Wall_Pass_BaseLightmap(msurface_t *s)
        m.numtriangles = s->mesh.numtriangles;
        m.numverts = s->mesh.numverts;
        m.index = s->mesh.index;
-       m.cr = 1;
-       if (lighthalf)
-               m.cr *= 2.0f;
-       m.cg = m.cr;
-       m.cb = m.cr;
+       m.cr = m.cg = m.cb = (float) (1 << v_overbrightbits.integer);
        m.ca = 1;
        m.tex[0] = R_GetTexture(s->lightmaptexture);
        m.texcoords[0] = &s->mesh.vertex->uv[0];
@@ -1115,12 +1088,12 @@ static void RSurfShader_Wall_Pass_BaseLightmap(msurface_t *s)
 
 static void RSurfShader_Wall_Pass_BaseVertex(msurface_t *s)
 {
-       int                             i, size3;
-       float                   c[3], base[3], scale, diff[3], ifog;
-       surfvertex_t    *v;
-       surfvert_t              *sv;
-       rmeshinfo_t             m;
-       byte                    *lm;
+       int i, size3;
+       float c[3], base[3], scale, diff[3], ifog;
+       surfvertex_t *v;
+       surfvert_t *sv;
+       rmeshinfo_t m;
+       qbyte *lm;
 
        size3 = ((s->extents[0]>>4)+1)*((s->extents[1]>>4)+1)*3;
 
@@ -1452,6 +1425,8 @@ static void RSurfShader_Wall_Pass_Fog(msurface_t *s)
 
 static int RSurfShader_Wall_Fullbright(int stage, msurface_t *s)
 {
+       if (stage == 0)
+               c_brush_polys++;
        switch(stage)
        {
        case 0:
@@ -1468,6 +1443,8 @@ static int RSurfShader_Wall_Fullbright(int stage, msurface_t *s)
 
 static int RSurfShader_Wall_Vertex(int stage, msurface_t *s)
 {
+       if (stage == 0)
+               c_brush_polys++;
        switch(stage)
        {
        case 0:
@@ -1484,6 +1461,8 @@ static int RSurfShader_Wall_Vertex(int stage, msurface_t *s)
 
 static int RSurfShader_Wall_Lightmap(int stage, msurface_t *s)
 {
+       if (stage == 0)
+               c_brush_polys++;
        if (r_vertexsurfaces.integer)
        {
                switch(stage)
@@ -1834,7 +1813,7 @@ static void R_PVSWorldNode()
        msurface_t *surf, **mark, **endmark;
        mleaf_t *leaf;
        tinyplane_t plane;
-       byte *worldvis;
+       qbyte *worldvis;
 
        worldvis = Mod_LeafPVS (r_viewleaf, cl.worldmodel);
 
@@ -2003,13 +1982,6 @@ done:;
        }
 }
 
-void R_DrawSurfacesAll (void)
-{
-       R_DrawSurfaces(SHADERSTAGE_SKY);
-       R_DrawSurfaces(SHADERSTAGE_NORMAL);
-       R_DrawSurfaces(SHADERSTAGE_FOG);
-}
-
 static float portalpointbuffer[256][3];
 
 void R_DrawPortals(void)