]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - r_shadow.c
fix more warnings
[xonotic/darkplaces.git] / r_shadow.c
index 49f03e4e4407a692950df8aace771fdac991e8b7..25f422faa220f1db9b722c508b312b0490c37186 100644 (file)
@@ -350,16 +350,6 @@ vec3_t r_editlights_cursorlocation;
 
 extern int con_vislines;
 
-typedef struct cubemapinfo_s
-{
-       char basename[64];
-       rtexture_t *texture;
-}
-cubemapinfo_t;
-
-static int numcubemaps;
-static cubemapinfo_t cubemaps[MAX_CUBEMAPS];
-
 void R_Shadow_UncompileWorldLights(void);
 void R_Shadow_ClearWorldLights(void);
 void R_Shadow_SaveWorldLights(void);
@@ -399,13 +389,13 @@ void R_Shadow_SetShadowMode(void)
                {
                        if(r_shadow_shadowmapfilterquality < 0)
                        {
-                               if(strstr(gl_vendor, "NVIDIA")) 
+                               if(vid.support.amd_texture_texture4 || vid.support.arb_texture_gather)
+                                       r_shadow_shadowmappcf = 1;
+                               else if(strstr(gl_vendor, "NVIDIA") || strstr(gl_renderer, "Radeon HD")) 
                                {
                                        r_shadow_shadowmapsampler = vid.support.arb_shadow;
                                        r_shadow_shadowmappcf = 1;
                                }
-                               else if(vid.support.amd_texture_texture4 || vid.support.arb_texture_gather) 
-                                       r_shadow_shadowmappcf = 1;
                                else if(strstr(gl_vendor, "ATI")) 
                                        r_shadow_shadowmappcf = 1;
                                else 
@@ -505,7 +495,6 @@ void R_Shadow_FreeShadowMaps(void)
 void r_shadow_start(void)
 {
        // allocate vertex processing arrays
-       numcubemaps = 0;
        r_shadow_attenuationgradienttexture = NULL;
        r_shadow_attenuation2dtexture = NULL;
        r_shadow_attenuation3dtexture = NULL;
@@ -581,7 +570,6 @@ void r_shadow_shutdown(void)
        r_shadow_prepass_width = r_shadow_prepass_height = 0;
 
        CHECKGLERROR
-       numcubemaps = 0;
        r_shadow_attenuationgradienttexture = NULL;
        r_shadow_attenuation2dtexture = NULL;
        r_shadow_attenuation3dtexture = NULL;
@@ -3426,7 +3414,10 @@ void R_Shadow_PrepareLight(rtlight_t *rtlight)
        float f;
        int numleafs, numsurfaces;
        int *leaflist, *surfacelist;
-       unsigned char *leafpvs, *shadowtrispvs, *lighttrispvs, *surfacesides;
+       unsigned char *leafpvs;
+       unsigned char *shadowtrispvs;
+       unsigned char *lighttrispvs;
+       //unsigned char *surfacesides;
        int numlightentities;
        int numlightentities_noselfshadow;
        int numshadowentities;
@@ -3455,7 +3446,7 @@ void R_Shadow_PrepareLight(rtlight_t *rtlight)
        }
 
        // load cubemap
-       rtlight->currentcubemap = rtlight->cubemapname[0] ? R_Shadow_Cubemap(rtlight->cubemapname) : r_texture_whitecube;
+       rtlight->currentcubemap = rtlight->cubemapname[0] ? R_GetCubemap(rtlight->cubemapname) : r_texture_whitecube;
 
        // look up the light style value at this time
        f = (rtlight->style >= 0 ? r_refdef.scene.rtlightstylevalue[rtlight->style] : 1) * r_shadow_lightintensityscale.value;
@@ -3490,7 +3481,7 @@ void R_Shadow_PrepareLight(rtlight_t *rtlight)
                leafpvs = rtlight->static_leafpvs;
                numsurfaces = rtlight->static_numsurfaces;
                surfacelist = rtlight->static_surfacelist;
-               surfacesides = NULL;
+               //surfacesides = NULL;
                shadowtrispvs = rtlight->static_shadowtrispvs;
                lighttrispvs = rtlight->static_lighttrispvs;
        }
@@ -3503,7 +3494,7 @@ void R_Shadow_PrepareLight(rtlight_t *rtlight)
                leaflist = r_shadow_buffer_leaflist;
                leafpvs = r_shadow_buffer_leafpvs;
                surfacelist = r_shadow_buffer_surfacelist;
-               surfacesides = r_shadow_buffer_surfacesides;
+               //surfacesides = r_shadow_buffer_surfacesides;
                shadowtrispvs = r_shadow_buffer_shadowtrispvs;
                lighttrispvs = r_shadow_buffer_lighttrispvs;
                // if the reduced leaf bounds are offscreen, skip it
@@ -3518,7 +3509,7 @@ void R_Shadow_PrepareLight(rtlight_t *rtlight)
                leafpvs = NULL;
                numsurfaces = 0;
                surfacelist = NULL;
-               surfacesides = NULL;
+               //surfacesides = NULL;
                shadowtrispvs = NULL;
                lighttrispvs = NULL;
        }
@@ -4482,140 +4473,6 @@ void R_Shadow_DrawCoronas(void)
 
 
 
-//static char *suffix[6] = {"ft", "bk", "rt", "lf", "up", "dn"};
-typedef struct suffixinfo_s
-{
-       char *suffix;
-       qboolean flipx, flipy, flipdiagonal;
-}
-suffixinfo_t;
-static suffixinfo_t suffix[3][6] =
-{
-       {
-               {"px",   false, false, false},
-               {"nx",   false, false, false},
-               {"py",   false, false, false},
-               {"ny",   false, false, false},
-               {"pz",   false, false, false},
-               {"nz",   false, false, false}
-       },
-       {
-               {"posx", false, false, false},
-               {"negx", false, false, false},
-               {"posy", false, false, false},
-               {"negy", false, false, false},
-               {"posz", false, false, false},
-               {"negz", false, false, false}
-       },
-       {
-               {"rt",    true, false,  true},
-               {"lf",   false,  true,  true},
-               {"ft",    true,  true, false},
-               {"bk",   false, false, false},
-               {"up",    true, false,  true},
-               {"dn",    true, false,  true}
-       }
-};
-
-static int componentorder[4] = {0, 1, 2, 3};
-
-rtexture_t *R_Shadow_LoadCubemap(const char *basename)
-{
-       int i, j, cubemapsize;
-       unsigned char *cubemappixels, *image_buffer;
-       rtexture_t *cubemaptexture;
-       char name[256];
-       // must start 0 so the first loadimagepixels has no requested width/height
-       cubemapsize = 0;
-       cubemappixels = NULL;
-       cubemaptexture = NULL;
-       // keep trying different suffix groups (posx, px, rt) until one loads
-       for (j = 0;j < 3 && !cubemappixels;j++)
-       {
-               // load the 6 images in the suffix group
-               for (i = 0;i < 6;i++)
-               {
-                       // generate an image name based on the base and and suffix
-                       dpsnprintf(name, sizeof(name), "%s%s", basename, suffix[j][i].suffix);
-                       // load it
-                       if ((image_buffer = loadimagepixelsbgra(name, false, false)))
-                       {
-                               // an image loaded, make sure width and height are equal
-                               if (image_width == image_height && (!cubemappixels || image_width == cubemapsize))
-                               {
-                                       // if this is the first image to load successfully, allocate the cubemap memory
-                                       if (!cubemappixels && image_width >= 1)
-                                       {
-                                               cubemapsize = image_width;
-                                               // note this clears to black, so unavailable sides are black
-                                               cubemappixels = (unsigned char *)Mem_Alloc(tempmempool, 6*cubemapsize*cubemapsize*4);
-                                       }
-                                       // copy the image with any flipping needed by the suffix (px and posx types don't need flipping)
-                                       if (cubemappixels)
-                                               Image_CopyMux(cubemappixels+i*cubemapsize*cubemapsize*4, image_buffer, cubemapsize, cubemapsize, suffix[j][i].flipx, suffix[j][i].flipy, suffix[j][i].flipdiagonal, 4, 4, componentorder);
-                               }
-                               else
-                                       Con_Printf("Cubemap image \"%s\" (%ix%i) is not square, OpenGL requires square cubemaps.\n", name, image_width, image_height);
-                               // free the image
-                               Mem_Free(image_buffer);
-                       }
-               }
-       }
-       // if a cubemap loaded, upload it
-       if (cubemappixels)
-       {
-               if (developer_loading.integer)
-                       Con_Printf("loading cubemap \"%s\"\n", basename);
-
-               if (!r_shadow_filters_texturepool)
-                       r_shadow_filters_texturepool = R_AllocTexturePool();
-               cubemaptexture = R_LoadTextureCubeMap(r_shadow_filters_texturepool, basename, cubemapsize, cubemappixels, TEXTYPE_BGRA, (gl_texturecompression_lightcubemaps.integer ? TEXF_COMPRESS : 0) | TEXF_FORCELINEAR, NULL);
-               Mem_Free(cubemappixels);
-       }
-       else
-       {
-               Con_DPrintf("failed to load cubemap \"%s\"\n", basename);
-               if (developer_loading.integer)
-               {
-                       Con_Printf("(tried tried images ");
-                       for (j = 0;j < 3;j++)
-                               for (i = 0;i < 6;i++)
-                                       Con_Printf("%s\"%s%s.tga\"", j + i > 0 ? ", " : "", basename, suffix[j][i].suffix);
-                       Con_Print(" and was unable to find any of them).\n");
-               }
-       }
-       return cubemaptexture;
-}
-
-rtexture_t *R_Shadow_Cubemap(const char *basename)
-{
-       int i;
-       for (i = 0;i < numcubemaps;i++)
-               if (!strcasecmp(cubemaps[i].basename, basename))
-                       return cubemaps[i].texture ? cubemaps[i].texture : r_texture_whitecube;
-       if (i >= MAX_CUBEMAPS)
-               return r_texture_whitecube;
-       numcubemaps++;
-       strlcpy(cubemaps[i].basename, basename, sizeof(cubemaps[i].basename));
-       cubemaps[i].texture = R_Shadow_LoadCubemap(cubemaps[i].basename);
-       return cubemaps[i].texture;
-}
-
-void R_Shadow_FreeCubemaps(void)
-{
-       int i;
-       for (i = 0;i < numcubemaps;i++)
-       {
-               if (developer_loading.integer)
-                       Con_Printf("unloading cubemap \"%s\"\n", cubemaps[i].basename);
-               if (cubemaps[i].texture)
-                       R_FreeTexture(cubemaps[i].texture);
-       }
-
-       numcubemaps = 0;
-       R_FreeTexturePool(&r_shadow_filters_texturepool);
-}
-
 dlight_t *R_Shadow_NewWorldLight(void)
 {
        return (dlight_t *)Mem_ExpandableArray_AllocRecord(&r_shadow_worldlightsarray);
@@ -4682,7 +4539,6 @@ void R_Shadow_ClearWorldLights(void)
                        R_Shadow_FreeWorldLight(light);
        }
        r_shadow_selectedlight = NULL;
-       R_Shadow_FreeCubemaps();
 }
 
 void R_Shadow_SelectLight(dlight_t *light)
@@ -5024,7 +4880,14 @@ typedef enum lighttype_e {LIGHTTYPE_MINUSX, LIGHTTYPE_RECIPX, LIGHTTYPE_RECIPXX,
 
 void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void)
 {
-       int entnum, style, islight, skin, pflags, effects, type, n;
+       int entnum;
+       int style;
+       int islight;
+       int skin;
+       int pflags;
+       //int effects;
+       int type;
+       int n;
        char *entfiledata;
        const char *data;
        float origin[3], angles[3], radius, color[3], light[4], fadescale, lightscale, originhack[3], overridecolor[3], vec[4];
@@ -5058,7 +4921,7 @@ void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void)
                style = 0;
                skin = 0;
                pflags = 0;
-               effects = 0;
+               //effects = 0;
                islight = false;
                while (1)
                {
@@ -5185,8 +5048,8 @@ void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void)
                                skin = (int)atof(value);
                        else if (!strcmp("pflags", key))
                                pflags = (int)atof(value);
-                       else if (!strcmp("effects", key))
-                               effects = (int)atof(value);
+                       //else if (!strcmp("effects", key))
+                       //      effects = (int)atof(value);
                        else if (cl.worldmodel->type == mod_brushq3)
                        {
                                if (!strcmp("scale", key))