diff --git a/NEW_RELEASE_NOTES.md b/NEW_RELEASE_NOTES.md index 4a1a9c7fa7..188a51f366 100644 --- a/NEW_RELEASE_NOTES.md +++ b/NEW_RELEASE_NOTES.md @@ -7,3 +7,5 @@ for next branch cut* header. appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md). ## Release notes for next branch cut + +- filagui: Fix regression which broke WebGL diff --git a/libs/filagui/include/filagui/ImGuiHelper.h b/libs/filagui/include/filagui/ImGuiHelper.h index 9ad4f0765e..3f55ac77bb 100644 --- a/libs/filagui/include/filagui/ImGuiHelper.h +++ b/libs/filagui/include/filagui/ImGuiHelper.h @@ -84,12 +84,14 @@ public: filament::View* mView; // The view is owned by the client. filament::Scene* mScene; filament::Material* mMaterial2d = nullptr; + std::vector mMaterial2dInstances; +#ifdef __ANDROID__ filament::Material* mMaterialExternal = nullptr; + std::vector mMaterialExternalInstances; +#endif filament::Camera* mCamera = nullptr; std::vector mVertexBuffers; std::vector mIndexBuffers; - std::vector mMaterial2dInstances; - std::vector mMaterialExternalInstances; utils::Entity mRenderable; utils::Entity mCameraEntity; filament::Texture* mTexture = nullptr; diff --git a/libs/filagui/src/ImGuiHelper.cpp b/libs/filagui/src/ImGuiHelper.cpp index 935ae138a4..1a88013125 100644 --- a/libs/filagui/src/ImGuiHelper.cpp +++ b/libs/filagui/src/ImGuiHelper.cpp @@ -64,10 +64,12 @@ ImGuiHelper::ImGuiHelper(Engine* engine, filament::View* view, const Path& fontP .package(FILAGUI_RESOURCES_UIBLIT_DATA, FILAGUI_RESOURCES_UIBLIT_SIZE) .constant("external", false) .build(*engine); +#ifdef __ANDROID__ mMaterialExternal = Material::Builder() .package(FILAGUI_RESOURCES_UIBLIT_DATA, FILAGUI_RESOURCES_UIBLIT_SIZE) .constant("external", true) .build(*engine); +#endif // If the given font path is invalid, ImGui will silently fall back to proggy, which is a // tiny "pixel art" texture that is compiled into the library. @@ -134,10 +136,12 @@ ImGuiHelper::~ImGuiHelper() { mEngine->destroy(mi); } mEngine->destroy(mMaterial2d); +#ifdef __ANDROID__ for (auto& mi : mMaterialExternalInstances) { mEngine->destroy(mi); } mEngine->destroy(mMaterialExternal); +#endif mEngine->destroy(mTexture); for (auto& vb : mVertexBuffers) { mEngine->destroy(vb); @@ -229,13 +233,16 @@ void ImGuiHelper::processImGuiCommands(ImDrawData* commands, const ImGuiIO& io) auto texture = (Texture const*)pcmd.TextureId; const char* uniformName; MaterialInstance* materialInstance; +#ifdef __ANDROID__ if (texture && texture->getTarget() == Texture::Sampler::SAMPLER_EXTERNAL) { if (materialExternalIndex == mMaterialExternalInstances.size()) { mMaterialExternalInstances.push_back(mMaterialExternal->createInstance()); } uniformName = "albedoExternal"; materialInstance = mMaterialExternalInstances[materialExternalIndex++]; - } else { + } else +#endif + { if (material2dIndex == mMaterial2dInstances.size()) { mMaterial2dInstances.push_back(mMaterial2d->createInstance()); }