cpp-gui-template-sdl2 icon indicating copy to clipboard operation
cpp-gui-template-sdl2 copied to clipboard

[Help Needed]: ImGui `AddFont` assertion failure when running SDL2 template

Open PerHac13 opened this issue 3 months ago • 5 comments

Description I’m trying to set up ImGui with SDL2 using this template. The build completes successfully, but when I run the app, it crashes with an assertion error from ImGui.


Steps to Reproduce

  1. Clone the repository.

  2. Build using the following commands:

    cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -B build/debug
    cmake --build build/debug
    
  3. Run:

    ./build/debug/src/app/App
    
  4. Observe the crash.

Note: A window briefly appears without any ImGui components before the application crashes. Running from WSL2 Ubuntu


Actual Behavior

[18:11:02] APP(debug): Current SDL_Renderer: opengl
[18:11:02] APP(debug): User config path: /path/.local/share/com.mycompany/BasicGuiProjectSetup/
App: /mypath/cpp-gui-template-sdl2/build/debug/_deps/imgui-src/imgui_draw.cpp:2535: ImFont* ImFontAtlas::AddFont(const ImFontConfig*): Assertion `font_cfg->SizePixels > 0.0f && "Is ImFontConfig struct correctly initialized?"' failed.
Aborted (core dumped)

Expected Behavior The application should run without crashing and display the default GUI.


Environment

  • OS:

    • Windows 11 (base)
    • Ubuntu 22.04 in WSL2 (running here)
  • Compiler: GCC 13.3.0

  • Build System: Ninja + CMake

  • CMake Version: 3.28.3


Additional Query

  • What is profile.json and why is it being saved to this path?

    User config path: /path/.local/share/com.mycompany/BasicGuiProjectSetup/
    

    Do I need to set up something for it manually?


Additional Context I’m new to setting up ImGui with SDL2. I chose this template because the documentation is great, but I still can’t figure out how to resolve the crash. Any help would be greatly appreciated!

Thanks

PerHac13 avatar Aug 12 '25 13:08 PerHac13