ImGuiHelper can construct with a context (#3753)

* ImGuiHelper supports client-provided context

this lets impress load >1 embedded  font into the font table

* ImGuiHelper supports client-provided context

this lets impress load >1 embedded  font into the font table

Co-authored-by: Philip Rideout <philiprideout@gmail.com>
This commit is contained in:
Adrian Perez
2021-04-05 10:42:57 -07:00
committed by GitHub
co-authored by Philip Rideout
parent 8a34f3c289
commit e29bfc2c86
2 changed files with 7 additions and 5 deletions
+2 -1
View File
@@ -47,7 +47,8 @@ public:
using Callback = std::function<void(filament::Engine*, filament::View*)>;
// The constructor creates its own Scene and places it in the given View.
ImGuiHelper(filament::Engine* engine, filament::View* view, const utils::Path& fontPath);
ImGuiHelper(filament::Engine* engine, filament::View* view, const utils::Path& fontPath,
ImGuiContext* imGuiContext = nullptr);
~ImGuiHelper();
// Informs ImGui of the current display size, as well as a scaling factor when scissoring.
+5 -4
View File
@@ -45,9 +45,10 @@ namespace filagui {
#include "generated/resources/filagui_resources.h"
ImGuiHelper::ImGuiHelper(Engine* engine, filament::View* view, const Path& fontPath) :
mEngine(engine), mView(view), mScene(engine->createScene()),
mImGuiContext(ImGui::CreateContext()) {
ImGuiHelper::ImGuiHelper(Engine* engine, filament::View* view, const Path& fontPath,
ImGuiContext *imGuiContext)
: mEngine(engine), mView(view), mScene(engine->createScene()),
mImGuiContext(imGuiContext ? imGuiContext : ImGui::CreateContext()) {
ImGuiIO& io = ImGui::GetIO();
// Create a simple alpha-blended 2D blitting material.
@@ -63,7 +64,7 @@ ImGuiHelper::ImGuiHelper(Engine* engine, filament::View* view, const Path& fontP
createAtlasTexture(engine);
// For proggy, switch to NEAREST for pixel-perfect text.
if (fontPath.isEmpty()) {
if (fontPath.isEmpty() && !imGuiContext) {
TextureSampler sampler(MinFilter::NEAREST, MagFilter::NEAREST);
mMaterial->setDefaultParameter("albedo", mTexture, sampler);
}