MCPcopy Create free account
hub / github.com/DentonW/DevIL / GetCubemapInfo

Function GetCubemapInfo

DevIL/src-IL/src/il_dds-save.cpp:74–132  ·  view source on GitHub ↗

Checks if an image is a cubemap

Source from the content-addressed store, hash-verified

72
73//! Checks if an image is a cubemap
74ILuint GetCubemapInfo(ILimage* image, ILint* faces)
75{
76 ILint indices[] = { -1, -1, -1, -1, -1, -1 }, i;
77 ILimage *img;
78 ILuint ret = 0, srcMipmapCount, srcImagesCount, mipmapCount;
79
80 if (image == NULL)
81 return 0;
82
83 iGetIntegervImage(image, IL_NUM_IMAGES, (ILint*) &srcImagesCount);
84 if (srcImagesCount != 5) //write only complete cubemaps (TODO?)
85 return 0;
86
87 img = image;
88 iGetIntegervImage(image, IL_NUM_MIPMAPS, (ILint*) &srcMipmapCount);
89 mipmapCount = srcMipmapCount;
90
91 for (i = 0; i < 6; ++i) {
92 switch (img->CubeFlags)
93 {
94 case DDS_CUBEMAP_POSITIVEX:
95 indices[i] = 0;
96 break;
97 case DDS_CUBEMAP_NEGATIVEX:
98 indices[i] = 1;
99 break;
100 case DDS_CUBEMAP_POSITIVEY:
101 indices[i] = 2;
102 break;
103 case DDS_CUBEMAP_NEGATIVEY:
104 indices[i] = 3;
105 break;
106 case DDS_CUBEMAP_POSITIVEZ:
107 indices[i] = 4;
108 break;
109 case DDS_CUBEMAP_NEGATIVEZ:
110 indices[i] = 5;
111 break;
112 }
113 iGetIntegervImage(img, IL_NUM_MIPMAPS, (ILint*) &srcMipmapCount);
114 if (srcMipmapCount != mipmapCount)
115 return 0; //equal # of mipmaps required
116
117 ret |= img->CubeFlags;
118 img = img->Next;
119 }
120
121 for (i = 0; i < 6; ++i)
122 if (indices[i] == -1)
123 return 0; //one face not found
124
125 if (ret != 0) //should always be true
126 ret |= DDS_CUBEMAP;
127
128 for (i = 0; i < 6; ++i)
129 faces[indices[i]] = i;
130
131 return ret;

Callers 1

iSaveDdsInternalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected