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

Function iLoadDdsCubemapInternal

DevIL/src-IL/src/il_dds.cpp:284–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282
283
284ILboolean iLoadDdsCubemapInternal(ILuint CompFormat)
285{
286 ILuint i;
287 ILubyte Bpp, Channels, Bpc;
288 ILimage *startImage;
289
290 CompData = NULL;
291
292 Bpp = iCompFormatToBpp(CompFormat);
293 Channels = iCompFormatToChannelCount(CompFormat);
294 Bpc = iCompFormatToBpc(CompFormat);
295 if (CompFormat == PF_LUMINANCE && Head.RGBBitCount == 16 && Head.RBitMask == 0xFFFF) { //@TODO: This is a HACK.
296 Bpc = 2; Bpp = 2;
297 }
298
299 startImage = Image;
300 // Run through cube map possibilities
301 for (i = 0; i < CUBEMAP_SIDES; i++) {
302 // Reset each time
303 Width = Head.Width;
304 Height = Head.Height;
305 Depth = Head.Depth;
306 if (Head.ddsCaps2 & CubemapDirections[i]) {
307 if (i != 0) {
308 Image->Faces = ilNewImage(Width, Height, Depth, Channels, Bpc);
309 if (Image->Faces == NULL)
310 return IL_FALSE;
311
312 Image = Image->Faces;
313
314 if (CompFormat == PF_R16F
315 || CompFormat == PF_G16R16F
316 || CompFormat == PF_A16B16G16R16F
317 || CompFormat == PF_R32F
318 || CompFormat == PF_G32R32F
319 || CompFormat == PF_A32B32G32R32F) {
320 // DevIL's format autodetection doesn't work for
321 // float images...correct this.
322 Image->Type = IL_FLOAT;
323 Image->Bpp = Channels;
324 }
325
326 ilBindImage(ilGetCurName()); // Set to parent image first.
327 //ilActiveImage(i); //@TODO: now Image == iCurImage...globals SUCK, fix this!!!
328 ilActiveFace(i);
329 }
330
331 if (!ReadData())
332 return IL_FALSE;
333
334 if (!AllocImage(CompFormat)) {
335 if (CompData) {
336 ifree(CompData);
337 CompData = NULL;
338 }
339 return IL_FALSE;
340 }
341

Callers 1

iLoadDdsInternalFunction · 0.85

Calls 9

iCompFormatToBppFunction · 0.85
iCompFormatToBpcFunction · 0.85
ilGetCurNameFunction · 0.85
ReadDataFunction · 0.85
AllocImageFunction · 0.85
DdsDecompressFunction · 0.85
ReadMipmapsFunction · 0.85
ilFixImageFunction · 0.85

Tested by

no test coverage detected