Skip to content

dinau/imguin_examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImGuin examples project

Confirmed ImGuin verion: v1.92.4.0 (Dear ImGui/CImGui version: 1.92.4) (2025/11)

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

Usage: Sample program and run


Prerequisites


  • Nim-2.2.6 or later

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

    pacman -S mingw-w64-x86_64-{gcc,glfw,SDL2,sdl3} make
  • Linux: Debian13 / Ubuntu families

    $ sudo apt install gcc g++ make 
    $ sudo apt install lib{opengl-dev,gl1-mesa-dev,glfw3,glfw3-dev,xcursor-dev,xinerama-dev,xi-dev,sdl2-dev} git 
    • If you have Debian13 Trixie

      $ sudo apt install libsdl3-dev

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 dep
  3. For instance glfw_opengl3_base.nim,

    pwd
    imguin_examples/glfw_opengl3_base
    make  # or make run

    After build, 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 2

    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

Basic example with icon fonts

alt

  • Build

    pwd
    glfw_opengl3
    make        # or   nim c glfw_opengl3.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_renderer / sdl3_renderer / sdl3_opengl3 / sdl3_sdlgpu3

SDL renderer backend.

  • Build sdl2 renderer backend

    pwd
    sdl2_renderer
    make     # or    nim c -d:SDL sdl2_renderer.nim  
  • Build sdl3 backend
    See SDL3 installation on Linux OS

    pwd
    sdl3_opengl3
    make     # or    nim c -d:SDL sdl3_opengl3.nim  
  • Build sdl3 renderer backend

    pwd
    sdl3_renderer
    make     # or    nim c -d:SDL sdl3_renderer.nim  
  • Build sdl3 GPU backend

    pwd
    sdl3_sdlgpu3
    make     # or    nim c -d:SDL sdl3_sdlgpu3.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
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.4
  • GCC (Rev1, Built by MSYS2 project) 15.2.0
  • Clang version 21.1.4
  • Visual Studio C++/C 2022
  • git version 2.46.0.windows.1
  • Make: GNU Make 4.4.1
  • MSys2/MinGW tools

Linux OS: Debain 13

  • Nim Compiler Version 2.2.4
  • 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)

  2. STATIC_LINK_GLFW = false can only be set at Dear ImGui 1.92.0 or later