Skip to content

The examples for ImGuin that ImGui wrapper for Nim language.

License

Notifications You must be signed in to change notification settings

dinau/imguin_examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImGuin examples project

alt alt

Confirmed ImGuin verion: : v1.91.6.10 (2025/01)

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

Usage: Sample program and run


Prerequisites


  • Nim-2.0.14 or later

  • Windows10 or later
    MSys2/MinGW command line tools (Unix tools), make, cp, rm, git, ...etc

  • Linux: Debian / Ubuntu families

    $ sudo apt install gcc g++ make git 
    $ sudo apt install xorg-dev libopengl-dev libgl1-mesa-dev
    $ sudo apt install libglfw3 libglfw3-dev libsdl2-dev

Build examples


  1. First clone this project,

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

    cd imguin_examples
    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)
    Compiation 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
v ImGui / CImGui Base library
v ImPlot / CImPlot
v ImNodes / CImNodes
v ImGuizmo / CImGuizmo
v ImGui-Knobs/ CImGui-Knobs
v ImGuiFileDialog / CImGuiFileDialog
... ... ...
x ImGuiColorTextEdit / cimCTE 2025 ?

Screen shot (examples)


These screen shots are on Windows10.


Basic example with icon fonts

alt

  • Build

    pwd
    glfw_opengl3
    make        # or make run

    or

    nim c glfw_opengl3.nim    # or  nim c -r glfw_opengl3.nim   or   nim r glfw_opengl3.nim 

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

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

alt

  • Build

    pwd
    glfw_opengl3_imknobs
    make 

    or

    nim c -d:ImKnobsEnable --warning:HoleEnumConv:off glfw_opengl3_imknobs.nim  

ImGuiFileDialog / CImGuiFileDialog

alt

  • Build

    pwd
    glfw_opengl3_filedialog
    make 

    or

    nim c -d:ImGuiFileDialogEnable  glfw_opengl3_filedialog.nim  

Icon font viewer and magnifying glass

alt

  • Build

    pwd
    iconFontViewer
    make 

    or

    nim c iconFontViewer.nim  

Image load and magnifying glass

alt

  • Build

    pwd
    glfw_opengl3_image_load
    make 

    or

    nim c glfw_opengl3_image_load.nim  
  • Build sdl2 version

    pwd
    sdl2_opengl3
    make 

    or

    nim c -d:SDL sdl2_opengl3.nim  
  • Build sdl3 version
    Only windows OS at this moment.

    pwd
    sdl3_opengl3
    make 

    or

    nim c -d:SDL sdl3_opengl3.nim  

SDL renderer backend.

  • Build sdl2 version

    pwd
    sdl2_renderer
    make 

    or

    nim c -d:SDL sdl2_renderer.nim  
  • Build sdl3 version
    Only windows OS at this moment.

    pwd
    sdl3_renderer
    make 

    or

    nim c -d:SDL sdl3_renderer.nim  

Image load / save and magnifying glass
It can save a screen shot as [ jpg, bmp, png or tga ] file.

alt

  • Build

    pwd
    glfw_opengl3_image_save
    make        # or make run

    or

    nim c glfw_opengl3_image_save.nim

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

  • Build

    pwd
    glfw_opengl3_jp
    make        # or make run

    or

    nim c glfw_opengl3_jp.nim

Showing ImGui demo with ImPlot demo.
alt

  • Build

    pwd
    glfw_opengl3_implot
    make        # or make run

    or

    nim c -d:ImPlotEnable glfw_opengl3_implot.nim

alt

  • Build

    pwd
    glfw_opengl3_imnodes
    make        # or make run

    or

    nim c -d:ImNodesEnable glfw_opengl3_imnodes.nim

alt

  • Build

    pwd
    glfw_opengl3_imguizmo
    make        # or make run

    or

    nim c -d:ImGuizmoEnable glfw_opengl3_imguizmo.nim
My test app movie using imguin

Sample movie,Youtube

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


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

For example on Linux Mint 22 and so on,

pwd
examples
cd glfw_opengl3
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.

Selection backend compiler


You might be able to use another C/C++ compiler,
Clang, vcc(Visual Studio C/C++) , zig cc
by changing variable TC in config.nims.common.

TODO


  1. Whether can it use cimgui.dll ? (Now it can only be static link) Closed. Only be static link.
  2. Easier compilation for SDL2 app. (2024/09) Done.
  3. Added: ImNodes/CImNodes (2023/10) Done
  4. Unfortunately ImGui 1.89.7 dosn't work well at this moment.(2023/07) Done. (2023/08)
  5. Whether can it do nimble install imguin ? Done (2023/09) (#Issue 13)
  6. Add Font Awesome (Icon Font) demo. Done (2023/04).
  7. Can it compile with MSVC (--cc:vcc) ? Done. Except SDL2 demo. (2023/03), TODO (2024/09)
  8. Can it compile with Clang (--cc:clang) ? Done. (2023/03)
  9. Add SDL2 example. Done. sdl2_opengl3 (2023/03)
  • First step is 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.0

  • GCC (Rev1, Built by MSYS2 project) 14.2.0

    pacman -S mingw-w64-ucrt-x86_64-gcc
  • Clang version 19.1.6

    pacman -S mingw-w64-ucrt-x86_64-clang
  • Visual Studio C++/C 2022

  • git version 2.46.0.windows.1

  • SDL2.dll: 2.30.7

  • Make: GNU Make 4.4.1

  • MSys2/MinGW tools

Linux Mint 22

  • Nim Compiler Version 2.2.0
  • gcc 13.2.0
  • SDL2: 2.30.0
  • make: GNU Make 4.3
  • git version 2.43.0

Other link


Similar project ImGui / CImGui

Language Project
Nim Compiler ImGuin, Nimgl_test, Nim_implot
Lua Script LuaJITImGui
Zig, C lang. Compiler Dear_Bindings_Build
Zig Compiler ImGuinZ
NeLua Compiler NeLuaImGui
Python Script DearPyGui for 32bit WindowsOS Binary
SDL Game tutorial Platfromer

ald

Language Project
Nim Compiler Nim-Platformer/ sdl3_nim
LuaJIT Script LuaJIT-Platformer
Nelua Compiler NeLua-Platformer
Zig Compiler 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

On Windows