Skip to content

Commit 42f0ef4

Browse files
committed
Fix imgui compile and link error for wasm (#2297)
1 parent c286f65 commit 42f0ef4

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

extensions/ImGui/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ add_library(${target_name} STATIC
7474
${HEADER}
7575
${SOURCE})
7676

77+
if(WASM)
78+
target_compile_definitions(${target_name} PRIVATE EMSCRIPTEN_USE_EMBEDDED_GLFW3=1)
79+
endif()
80+
7781
target_include_directories(${target_name}
7882
PUBLIC src
7983
PUBLIC src/ImGui/imgui

extensions/ImGui/src/ImGui/imgui/imgui.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3573,9 +3573,9 @@ struct ImFont
35733573
// Methods
35743574
IMGUI_API ImFont();
35753575
IMGUI_API ~ImFont();
3576-
IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c);
3577-
IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c);
3578-
float GetCharAdvance(ImWchar c) { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
3576+
IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const;
3577+
IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c) const;
3578+
float GetCharAdvance(ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
35793579
bool IsLoaded() const { return ContainerAtlas != NULL; }
35803580
const char* GetDebugName() const { return ConfigData ? ConfigData->Name : "<unknown>"; }
35813581

@@ -3593,7 +3593,7 @@ struct ImFont
35933593
IMGUI_API void AddGlyph(const ImFontConfig* src_cfg, ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x);
35943594
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
35953595
IMGUI_API void SetGlyphVisible(ImWchar c, bool visible);
3596-
IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last);
3596+
IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last) const;
35973597
};
35983598

35993599
//-----------------------------------------------------------------------------

extensions/ImGui/src/ImGui/imgui/imgui_draw.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3770,7 +3770,7 @@ void ImFont::BuildLookupTable()
37703770

37713771
// API is designed this way to avoid exposing the 4K page size
37723772
// e.g. use with IsGlyphRangeUnused(0, 255)
3773-
bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last)
3773+
bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last) const
37743774
{
37753775
unsigned int page_begin = (c_begin / 4096);
37763776
unsigned int page_last = (c_last / 4096);
@@ -3860,7 +3860,7 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
38603860
}
38613861

38623862
// Find glyph, return fallback if missing
3863-
const ImFontGlyph* ImFont::FindGlyph(ImWchar c)
3863+
const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const
38643864
{
38653865
if (c >= (size_t)IndexLookup.Size)
38663866
return FallbackGlyph;
@@ -3870,7 +3870,7 @@ const ImFontGlyph* ImFont::FindGlyph(ImWchar c)
38703870
return &Glyphs.Data[i];
38713871
}
38723872

3873-
const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c)
3873+
const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const
38743874
{
38753875
if (c >= (size_t)IndexLookup.Size)
38763876
return NULL;

0 commit comments

Comments
 (0)