MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Init

Method Init

Source/Engine/Graphics/Textures/TextureBase.cpp:638–683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

636}
637
638bool TextureBase::Init(InitData* initData)
639{
640 // Validate state
641 if (!IsVirtual())
642 {
643 LOG(Error, "Texture must be virtual.");
644 Delete(initData);
645 return true;
646 }
647 if (initData->Format == PixelFormat::Unknown ||
648 Math::IsNotInRange(initData->Width, 1, GPU_MAX_TEXTURE_SIZE) ||
649 Math::IsNotInRange(initData->Height, 1, GPU_MAX_TEXTURE_SIZE) ||
650 Math::IsNotInRange(initData->ArraySize, 1, GPU_MAX_TEXTURE_ARRAY_SIZE) ||
651 Math::IsNotInRange(initData->Mips.Count(), 1, GPU_MAX_TEXTURE_MIP_LEVELS))
652 {
653 Log::ArgumentOutOfRangeException();
654 Delete(initData);
655 return true;
656 }
657 ScopeLock lock(Locker);
658
659 // Release texture
660 _texture.UnloadTexture();
661
662 // Prepare descriptor
663 if (_customData != nullptr)
664 Delete(_customData);
665 _customData = initData;
666
667 // Create texture
668 TextureHeader textureHeader;
669 textureHeader.Format = _customData->Format;
670 textureHeader.Width = _customData->Width;
671 textureHeader.Height = _customData->Height;
672 textureHeader.IsCubeMap = _customData->ArraySize == 6;
673 textureHeader.MipLevels = _customData->Mips.Count();
674 textureHeader.Type = TextureFormatType::ColorRGBA;
675 textureHeader.NeverStream = true;
676 if (_texture.Create(textureHeader))
677 {
678 LOG(Warning, "Cannot initialize texture.");
679 return true;
680 }
681
682 return false;
683}
684
685#if !COMPILE_WITHOUT_CSHARP
686

Callers

nothing calls this directly

Calls 7

IsVirtualFunction · 0.85
DeleteFunction · 0.85
IsNotInRangeFunction · 0.85
UnloadTextureMethod · 0.80
CountMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected