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

Method GetTexture

Source/Editor/Utilities/EditorUtilities.cpp:97–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97bool EditorUtilities::GetTexture(const Guid& textureId, TextureData& textureData)
98{
99 AssetReference<Texture> texture = Content::LoadAsync<Texture>(textureId);
100 if (texture)
101 {
102 if (texture->WaitForLoaded())
103 {
104 LOG(Warning, "Waiting for the texture to be loaded failed.");
105 }
106 else
107 {
108 const bool useGPU = texture->IsVirtual();
109 if (useGPU)
110 {
111 int32 waits = 1000;
112 const auto targetResidency = texture->StreamingTexture()->GetMaxResidency();
113 ASSERT(targetResidency > 0);
114 while (targetResidency != texture->StreamingTexture()->GetCurrentResidency() && waits-- > 0)
115 {
116 Platform::Sleep(10);
117 }
118
119 // Get texture data from GPU
120 if (!texture->GetTexture()->DownloadData(textureData))
121 return false;
122 }
123
124 // Get texture data from asset
125 if (!texture->GetTextureData(textureData))
126 return false;
127
128 LOG(Warning, "Loading texture data failed.");
129 }
130 }
131 return true;
132}
133
134bool EditorUtilities::ExportApplicationImage(const Guid& iconId, int32 width, int32 height, PixelFormat format, const String& path, ApplicationImageType type)
135{

Callers 15

GetCustomOrDefaultFunction · 0.80
getDofBokehShapeMethod · 0.80
RenderMethod · 0.80
RenderLightsMethod · 0.80
RenderMethod · 0.80
RenderMethod · 0.80
RenderMethod · 0.80
BindMethod · 0.80
WaitForLightmapsMethod · 0.80
onJobRenderMethod · 0.80
WaitForAssetMethod · 0.80

Calls 7

WaitForLoadedMethod · 0.80
IsVirtualMethod · 0.80
StreamingTextureMethod · 0.80
GetTextureDataMethod · 0.80
GetMaxResidencyMethod · 0.45
GetCurrentResidencyMethod · 0.45
DownloadDataMethod · 0.45

Tested by

no test coverage detected