Skip to content

dinau/imguin_examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImGuin examples project

Confirmed ImGuin verion: v1.92.6.1
(Dear ImGui/CImGui version: 1.92.6dock) (2026/02)

This is example project to use Dear ImGui, ImPlot and so on in Nim language.
Wrapper libraies used are here ImGuin 1

Try Wasm demo in your browser


Click link for live demo: glfw_opengl3_wasm_base
alt

See Wasm-example: glfw_opengl3_wasm_base

Usage: Sample program and run


Prerequisites


  • Nim-2.2.8 or later

  • Windows11 MSys2/MinGW installed: Command line tools: make, python, cp, rm, git, ...etc

    pacman -S mingw-w64-ucrt-x86_64-{gcc,glfw,SDL2,sdl3,pkgconf} make
    pacman -S mingw-w64-ucrt-x86_64-vulkan-{headers,loader}
  • Linux: Debian / Ubuntu families

    $ sudo apt install build-essential pkgconf
    $ sudo apt install lib{opengl-dev,gl1-mesa-dev,glfw3,glfw3-dev,xcursor-dev,xinerama-dev,xi-dev,sdl2-dev} git 
    $ sudo apt install libvulkan-dev

Frontends and Backends


Frontends Backends
GLFW OpenGL3, Vulkan
SDL2 OpenGL3, sdlrenderer2
SDL3 OpenGL3, sdlrenderer3, sdlgpu3, Vulkan
Wasm WebGL 2.0

Build examples


  1. First clone this project,

    git clone https://github.com/dinau/imguin_examples
  2. Install dependencies libraries,

    cd imguin_examples
    nimble refresh
    nimble install -d
  3. For instance glfw_opengl3_base.nim

    pwd
    imguin_examples/glfw_opengl3_base
    make  # or make run

    After building, run ./glfw_opengl3_base(.exe)
    Compilation options depend on ./config.nims and ./Makefile.

  4. Selecting static link or dynamic link.
    If you'd like to build executables with static link (not using *.dll),
    edit ./linkControl.nim in respective example folder.
    To not depend on any other *.dll files,
    change to

    const STATIC_LINK_GLFW = true   # if true, it doesn't need glfw3.dll
    const STATIC_LINK_CC   = true   # if true, it doesn't need libstd++-6.dll

Available libraries


Library name / C lang wrapper

Additional examples

Screenshot (examples)


These screenshots are on Windows10.

glfw_opengl3 / glfw_vulkan

Basic example with icon fonts

alt

  • Build

    pwd
    glfw_opengl3
    make        # or   nim c glfw_opengl3.nim

    Vulkan

    pwd
    glfw_vulkan
    make        # or   nim c glfw_vulkan.nim
glfw_opengl3_imknobs

https://github.com/altschuler/imgui-knobs

cimgui-knobs sources have been contributed from system64MC / PR (2024/12). Thank you.

alt

pwd
glfw_opengl3_imknobs
make     # or  nim c -d:ImKnobs glfw_opengl3_imknobs.nim  
glfw_opengl3_filedialog

ImGuiFileDialog / CImGuiFileDialog

alt

pwd
glfw_opengl3_filedialog
make    # or   nim c -d:ImGuiFileDialog glfw_opengl3_filedialog.nim  
glfw_opengl3_imgui_toggle

alt

pwd
glfw_opengl3_imgui_toggle
make    # or   nim c -d:ImGuiToggle glfw_opengl3_imgui_toggle.nim  
glfw_opengl3_imguiTextSelect

alt

alt

pwd
glfw_opengl3_imguiTextSelect
make    # or    nim c -d:ImGuiTextSelect  glfw_opengl3_imguiTextSelect.nim  
glfw_opengl3_imspinner

alt
alt

pwd
glfw_opengl3_imspinner
make    # or    nim c -d:ImSpinner glfw_opengl3_imspinner.nim  
rlimgui_basic (Naylib / Raylib / rlImgui)

alt

pwd
rlimgui_basic
make    # or    nim c rlimgui_basic.nim  
glfw_opengl3_iconfont_viewer

Icon font viewer.

  • Magnifying glass
  • Incremantal search

alt

pwd
iconFontViewer
make       # or    nim c iconFontViewer.nim  
glfw_opengl3_image_load / sdl2_opengl3

  • Image loading
  • Magnifying glass

alt

pwd
glfw_opengl3_image_load
make     # or    nim c glfw_opengl3_image_load.nim  
  • sdl2 version

    pwd
    sdl2_opengl3
    make     # or    nim c -d:SDL sdl2_opengl3.nim  
sdl2: opengl3 / renderer

  • Build sdl2 + OpenGL3 backend

    cd sdl2_opengl3
    make     # or    nim c -d:SDL sdl2_opengl3.nim  
  • Build sdl2 renderer backend

    cd sdl2_renderer
    make     # or    nim c -d:SDL sdl2_renderer.nim  
sdl3: opengl3 / renderer / sdlgpu3 / vulkan

  • Build SDL3 + OpenGL backend
    See SDL3 installation on Linux OS

    cd sdl3_opengl3
    make     # or    nim c -d:SDL sdl3_opengl3.nim  
  • Build SDL3 + SDL3 renderer backend

    cd sdl3_renderer
    make     # or    nim c -d:SDL sdl3_renderer.nim  
  • Build SDL3 + SDL3 GPU backend

    cd sdl3_sdlgpu3
    make     # or    nim c -d:SDL sdl3_sdlgpu3.nim  
  • Build SDL3 + Vulkan backend

    cd sdl3_vulkan
    make     # or    nim c -d:SDL -d:volk sdl3_vulkan.nim  
glfw_opengl3_image_save

  • Image loading / saving
    It can save a screenshot as [ jpg, bmp, png or tga ] file.
  • Magnifying glass

alt

pwd
glfw_opengl3_image_save
make        # or   nim c glfw_opengl3_image_save.nim
glfw_opengl3_jp

Showing UTF-8 text and input text with a local country language.
alt

pwd
glfw_opengl3_jp
make        # or    nim c glfw_opengl3_jp.nim

If you are on Debian13 in WSL2 on Windows OS,

sudo apt install fonts-ipafont
glfw_opengl3_implot

Showing ImGui demo with ImPlot demo.
alt

pwd
glfw_opengl3_implot
make        # or    nim c -d:ImPlot glfw_opengl3_implot.nim
glfw_opengl3_implot3d

Showing ImPlot3D demo. WIP

alt alt

pwd
glfw_opengl3_implot3d
make       # or   nim c -d:ImPlot3D glfw_opengl3_implot3d.nim
glfw_opengl3_imnodes

alt

pwd
glfw_opengl3_imnodes
make        # or    nim c -d:ImNodes glfw_opengl3_imnodes.nim
glfw_opengl3_imguizmo

alt

pwd
glfw_opengl3_imguizmo
make        # or    nim c -d:ImGuizmo glfw_opengl3_imguizmo.nim
glfw_opengl3_imColorTextEdit

alt

pwd
glfw_opengl3_imColorTextEdit
make        # or    nim c -d:ImColorTextEdit glfw_opengl3_imColorTextEdit.nim
glfw_opengl3_imgui_markdown

WIP at this moment.

alt

pwd
glfw_opengl3_imgui_markdown
make        # or     nim c -d:ImGuiMarkdown glfw_opengl3_imgui_markdown.nim

Wasm example: glfw_opengl3_wasm_base


  1. Install emcc compiler from emsdk
    Reference to nim_emscripten_tutorial

  2. Confirm emcc version

    $ emcc --version
    emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 5.0.4 (62e22652509fbe7a00609ce48a653d0d66f27ba5)
    --- snip ---
  3. Build contrib.glfw3

    $ embuilder build contrib.glfw3
  4. Build example

    pwd
    glfw_opengl3_wasm_base
    $ make        # or  nim c -d:strip -d:emscripten glfw_opengl3_wasm_base.nim
  5. Run example in Web browser

    $ make run
    
    python -m http.server 8000
    Serving HTTP on :: port 8000 (http://[::]:8000/) ...
    ::ffff:127.0.0.1 - - [28/Mar/2026 19:25:12] "GET / HTTP/1.1" 200 -
    ::ffff:127.0.0.1 - - [28/Mar/2026 19:27:14] "GET /glfw_opengl3_wasm.html HTTP/1.1" 200 -
    ::ffff:127.0.0.1 - - [28/Mar/2026 19:27:14] "GET /glfw_opengl3_wasm.js HTTP/1.1" 200 -
    ::ffff:127.0.0.1 - - [28/Mar/2026 19:27:14] "GET /glfw_opengl3_wasm.wasm HTTP/1.1" 200 -

    Click http://[::]:8000/ or http://[localhost]:8000/ or open it on your browser
    and click glfw_opengl3_wasm_base.html

  6. Genarete desktop application

    $ make app

    ./glfw_opengl3_wasm_base(.exe) can be executed as desktop application.

My test app movie using imguin


Sample movie,Youtube

Cross compilation: Generating Windows application binary(*.exe) on Linux OS


  1. See:
    Cross compilation to Windows, linker error (unrecognized option '-z'
    https://nim-lang.org/docs/nimc.html#crossminuscompilation-for-windows

  2. Download GLFW3 Windows pre-compiled binaries form here.

  3. Extracts glfw-3.4.bin.WIN64.zip

  4. cp glfw-3.4.bin.WIN64/lib-mingw-w64/{glfw3.dll,libglfw3dll.a} imguin_examples/glfw_opengl3/
  5. Rename lib name

    pwd
    imguin_examples/glfw_opengl3
    mv libglfw3dll.a libglfw3.dll.a
  6. Edit Makefile
    Add the following line to imguin_examples/glfw_opengl3/Makefile

    OPT += -d:release
    OPT += --passL:"-L ."    # <----- added line
    
    include ../makefile.common.mk
    
  7. Run make to build example

    make win

    or

    nim c -d:mingw glfw_opengl3
    or 
    nim c --os:windows glfw_opengl3

    glfw_opengl3.exe will be generated in the current folder.

TODO


  • Can it compile with zig cc ? Done. But Zig lang. is very unstable at this time.
  • Whether can it use cimgui.dll ? (Now it can only be static link) Closed. Only be static link.
  • Easier compilation for SDL2 app. (2024/09) Done.
  • Added: ImNodes/CImNodes (2023/10) Done
  • Unfortunately Dear ImGui - 1.89.7 dosn't work well at this moment.(2023/07) Done. (2023/08)
  • Whether can it do nimble install imguin ? Done (2023/09) (#Issue 13)
  • Add Font Awesome (Icon Font) demo. Done (2023/04).
  • Can it compile with MSVC (--cc:vcc) ? Done. Except SDL2 demo. (2023/03), TODO (2024/09)
  • Can it compile with Clang (--cc:clang) ? Done. (2023/03)
  • Add SDL2 example. Done. sdl2_opengl3 (2023/03)
  • First step has been done. (2023/03)

Compressing binary file


Install UPX with MSys console on WindowsOS,

pacman -S mingw-w64-x86_64-upx

For compression exe file,

pwd
examples
cd glfw_opengl3_implot
make upx
                       Ultimate Packer for eXecutables
                          Copyright (C) 1996 - 2024
UPX 4.2.4       Markus Oberhumer, Laszlo Molnar & John Reiser    May 9th 2024

        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
   7117824 ->   1217024   17.10%    win64/pe     glfw_opengl3_implot.exe      

Decompressing,

make dupx

Result in,

GCC + UPX : GCC Clang + UPX : Clang MSVC(vcc) + UPX : MSVC
glfw_opengl3.exe 804 KB : 2360 KB 720 KB : 2200 KB 742 KB : 2070 KB
glfw_opengl3_implot.exe 1220 KB : 7120 KB 940KB : 4200 KB 945 KB : 3810 KB

GCC: v14.2.0, Clang: v18.1.8, MSVC: 2022

My tools version


Windows11 (main)

  • Nim Compiler Version 2.2.8
  • GCC (Rev1, Built by MSYS2 project) 15.2.0
  • Clang version 21.1.8
  • Visual Studio C++/C 2022
  • git version 2.46.0.windows.1
  • Make: GNU Make 4.4.1
  • MSys2/MinGW tools

WSL2 Linux OS: Debain 13

  • Nim Compiler Version 2.2.6
  • gcc 14.2.0
  • make: GNU Make 4.4.1
  • git version 2.47.3

Other link


Similar project ImGui / CImGui


alt

Language Project
Lua Script LuaJITImGui
NeLua Compiler NeLuaImGui / NeLuaImGui2
Nim Compiler ImGuin, Nimgl_test, Nim_implot
Python Script DearPyGui for 32bit WindowsOS Binary
Ruby Script igRuby_Examples
Zig, C lang. Compiler Dear_Bindings_Build
Zig Compiler ImGuinZ

SDL Game tutorial Platfromer


ald

Language SDL Project
LuaJIT Script SDL2 LuaJIT-Platformer
Nelua Compiler SDL2 NeLua-Platformer
Nim Compiler SDL3 / SDL2 Nim-Platformer-sdl2/ Nim-Platformer-sdl3
Ruby Script SDL3 Ruby-Platformer
Zig Compiler SDL3 / SDL2 Zig-Platformer

Other link2


Memo


error: assignment to 'char **' from incompatible pointer type 'const char * const*' [-Wincompatible-pointer-types]
type ConstCstring {.importc: const char *.} = cstring

Notes:

  • Using ImPlot3D / ImPlot with Nim
  • Nim + ImGui + ImPlot3D / ImPlot demo
  • Build with ImPlot3D / ImPlot
  • ImPlot3D integration example
  • This project builds and runs Dear ImGui + ImPlot3D / ImPlotusing Nim.
  • ImPlot3D is compiled from source (implot3d.h / implot3d.cpp)
  • ImPlot is compiled from source (implot.h / implot.cpp)

Footnotes

  1. It may be better to use the mainstream project nimgl/imgui (ImGui v1.85)
    ,updated project nimgl-imgui (ImGui v1.89.9) ,sub project nim_implot and test project nimgl_test,
    or https://github.com/daniel-j/nimgl-imgui(ImGui v1.91.1)