]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added comments to cubemap loader, to explain its confusing logic
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 15 May 2004 20:40:07 +0000 (20:40 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 15 May 2004 20:40:07 +0000 (20:40 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4170 d7cf8633-e32d-0410-b094-e92efae38249

r_shadow.c

index 646fac0e65f1b918d3cb907013d85eb45045e8b7..872c159a4faa1446636b5a9400bee095edb219ae 100644 (file)
@@ -2290,30 +2290,39 @@ rtexture_t *R_Shadow_LoadCubemap(const char *basename)
        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
                        snprintf(name, sizeof(name), "%s%s", basename, suffix[j][i].suffix);
+                       // load it
                        if ((image_rgba = loadimagepixels(name, false, cubemapsize, cubemapsize)))
                        {
+                               // an image loaded, make sure width and height are equal
                                if (image_width == image_height)
                                {
+                                       // 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 sizes are black
+                                               // note this clears to black, so unavailable sides are black
                                                cubemappixels = 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_rgba, 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_rgba);
                        }
                }
        }
+       // if a cubemap loaded, upload it
        if (cubemappixels)
        {
                if (!r_shadow_filters_texturepool)