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:
co-authored by
Philip Rideout
parent
8a34f3c289
commit
e29bfc2c86
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user