I’m attempted to use a dynamic texture on Android. It works on Windows, but when I package for Android, it doesn’t work.
Everything works on Android except my dynamic texture is not successfully changed (written to) by my C++ code.
I’m not sure how to debug this? I tried UE_LOG(), but for some reason (adb logcat) doesn’t show my messages. Blueprints function Print doesn’t work either.
The following C++ code is called every tick by the Blueprints script for an actor that uses the texture:
…
UTexture2D* ABoardActor::GetBoardTexture(UTexture2D* tex)
{
//
//TODO: track whether update was already done, actually better yet do a callback to blueprints
//
UE_LOG(HeroQuestLog, Log, TEXT("BOARD 1"));
HQMap* pMap = HQMap::GetTheMap();
FTexture2DMipMap& Mip = tex->PlatformData->Mips[0];
FColor* FormatedImageData = static_cast<FColor*>(Mip.BulkData.Lock(LOCK_READ_WRITE));
int32 width = Mip.SizeX;
int32 height = Mip.SizeY;
UE_LOG(HeroQuestLog, Log, TEXT("BOARD 2"));
for (int32 y = 0; y < height; ++y)
{
for (int32 x = 0; x < width; ++x)
{
FColor pixColor(0, 0, 0);
HQSpace* pSpace = pMap->GetSpace(x, y);
if (pSpace && pSpace->IsRevealed())
{
pixColor.R = 255;
pixColor.G = 255;
pixColor.B = 255;
pixColor.A = 255;
}
else
{
pixColor.R = 70;
pixColor.G = 70;
pixColor.B = 70;
pixColor.A = 70;
}
FormatedImageData[y * width + x].R = pixColor.R;
FormatedImageData[y * width + x].G = pixColor.G;
FormatedImageData[y * width + x].B = pixColor.B;
}
}
UE_LOG(HeroQuestLog, Log, TEXT("BOARD 3"));
Mip.BulkData.Unlock();
tex->UpdateResource();
UE_LOG(HeroQuestLog, Log, TEXT("BOARD 4"));
return tex;
}
Update: Is there some way to tell whether it’s a UE4 bug vs. not supported on Android vs. not supported on my particular tablet? It seems like it should be supported because after all I’m not updating the texture every frame. So really any device that supports an OpenGL texture should support this because the run-time texture edit doesn’t need to be high performance.
Update #2: adb logcat shows (E/libEGL ( 703): called unimplemented OpenGL ES API)), but I don’t know what’s causing it. I don’t even know whether it’s a real issue vs. a red herring?
Update #3: Has anyone seen a dynamic texture work on Android? Can you share sample code?