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

Function AllocImage

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

Source from the content-addressed store, hash-verified

679
680
681ILboolean AllocImage(ILuint CompFormat)
682{
683 ILubyte channels = 4;
684 ILenum format = IL_RGBA;
685
686 switch (CompFormat)
687 {
688 case PF_RGB:
689 if (!ilTexImage(Width, Height, Depth, 3, IL_RGB, IL_UNSIGNED_BYTE, NULL))
690 return IL_FALSE;
691 break;
692 case PF_ARGB:
693 if (!ilTexImage(Width, Height, Depth, 4, IL_RGBA, Has16BitComponents ? IL_UNSIGNED_SHORT : IL_UNSIGNED_BYTE, NULL))
694 return IL_FALSE;
695 break;
696
697 case PF_LUMINANCE:
698 if (Head.RGBBitCount == 16 && Head.RBitMask == 0xFFFF) { //HACK
699 if (!ilTexImage(Width, Height, Depth, 1, IL_LUMINANCE, IL_UNSIGNED_SHORT, NULL))
700 return IL_FALSE;
701 }
702 else
703 if (!ilTexImage(Width, Height, Depth, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, NULL))
704 return IL_FALSE;
705 break;
706
707 case PF_LUMINANCE_ALPHA:
708 if (!ilTexImage(Width, Height, Depth, 2, IL_LUMINANCE_ALPHA, IL_UNSIGNED_BYTE, NULL))
709 return IL_FALSE;
710 break;
711
712 case PF_ATI1N:
713 //right now there's no OpenGL api to use the compressed 3dc data, so
714 //throw it away (I don't know how DirectX works, though)?
715 if (!ilTexImage(Width, Height, Depth, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, NULL))
716 return IL_FALSE;
717 break;
718
719 case PF_3DC:
720 //right now there's no OpenGL api to use the compressed 3dc data, so
721 //throw it away (I don't know how DirectX works, though)?
722 if (!ilTexImage(Width, Height, Depth, 3, IL_RGB, IL_UNSIGNED_BYTE, NULL))
723 return IL_FALSE;
724 break;
725
726 case PF_A16B16G16R16:
727 if (!ilTexImage(Width, Height, Depth, iCompFormatToChannelCount(CompFormat),
728 ilGetFormatBpp(iCompFormatToChannelCount(CompFormat)), IL_UNSIGNED_SHORT, NULL))
729 return IL_FALSE;
730 break;
731
732 case PF_R16F:
733 case PF_G16R16F:
734 case PF_A16B16G16R16F:
735 case PF_R32F:
736 case PF_G32R32F:
737 case PF_A32B32G32R32F:
738 if (!ilTexImage(Width, Height, Depth, iCompFormatToChannelCount(CompFormat),

Callers 2

iLoadDdsCubemapInternalFunction · 0.85
iLoadDdsInternalFunction · 0.85

Calls 2

ilGetFormatBppFunction · 0.85

Tested by

no test coverage detected