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

Function iLoadDdsInternal

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

Source from the content-addressed store, hash-verified

370
371
372ILboolean iLoadDdsInternal()
373{
374 ILuint BlockSize = 0;
375 ILuint CompFormat;
376
377 CompData = NULL;
378 Image = NULL;
379
380 if (iCurImage == NULL) {
381 ilSetError(IL_ILLEGAL_OPERATION);
382 return IL_FALSE;
383 }
384
385 if (!iGetDdsHead(&Head)) {
386 ilSetError(IL_INVALID_FILE_HEADER);
387 return IL_FALSE;
388 }
389 if (!iCheckDds(&Head)) {
390 ilSetError(IL_INVALID_FILE_HEADER);
391 return IL_FALSE;
392 }
393
394 BlockSize = DecodePixelFormat(&CompFormat);
395 if (CompFormat == PF_UNKNOWN) {
396 ilSetError(IL_INVALID_FILE_HEADER);
397 return IL_FALSE;
398 }
399 Check16BitComponents(&Head);
400
401 // Microsoft bug, they're not following their own documentation.
402 if (!(Head.Flags1 & (DDS_LINEARSIZE | DDS_PITCH))
403 || Head.LinearSize == 0) {
404 Head.Flags1 |= DDS_LINEARSIZE;
405 Head.LinearSize = BlockSize;
406 }
407
408 Image = iCurImage;
409 if (Head.ddsCaps1 & DDS_COMPLEX) {
410 if (Head.ddsCaps2 & DDS_CUBEMAP) {
411 if (!iLoadDdsCubemapInternal(CompFormat))
412 return IL_FALSE;
413 return IL_TRUE;
414 }
415 }
416
417 Width = Head.Width;
418 Height = Head.Height;
419 Depth = Head.Depth;
420 AdjustVolumeTexture(&Head, CompFormat);
421
422 if (!ReadData())
423 return IL_FALSE;
424 if (!AllocImage(CompFormat)) {
425 if (CompData) {
426 ifree(CompData);
427 CompData = NULL;
428 }
429 return IL_FALSE;

Callers 2

ilLoadDdsFFunction · 0.85
ilLoadDdsLFunction · 0.85

Calls 13

ilSetErrorFunction · 0.85
iGetDdsHeadFunction · 0.85
iCheckDdsFunction · 0.85
DecodePixelFormatFunction · 0.85
Check16BitComponentsFunction · 0.85
iLoadDdsCubemapInternalFunction · 0.85
AdjustVolumeTextureFunction · 0.85
ReadDataFunction · 0.85
AllocImageFunction · 0.85
DdsDecompressFunction · 0.85
ReadMipmapsFunction · 0.85
ilGetCurNameFunction · 0.85

Tested by

no test coverage detected