dinau / imguin

Dear Imgui / CImGui, ImPlot/CImPlot wrapper for Nim language
MIT License
29 stars 2 forks source link
awesome cimgui cimguizmo cimplot debian font futhark glfw gui icon imgui imnodes implot nim nim-lang nimgl opengl sdl windows

ImGuin

Updated to latest ImGui/CImGui version: : v1.91.4dock (2024/10)

This project is my experiment project to use Nim language, ImGui, ImPlot, futhark and etc.

Usage: Sample program and run


Prerequisites


Install


nimble uninstall imguin  # Remove old versions if exist. 
nimble install https://github.com/dinau/imguin

Build examples


  1. First clone this project,

    git clone https://github.com/dinau/imguin
  2. Sample program is here, examples. For instance glfw_opengl3.nim,

    cd imguin/examples/glfw_opengl3
    make  # or make run

    After build, run ./glfw_opengl3(.exe)

  3. For selecting static link or dynamic link ,read this examples/README.md.

Screen shot (examples)


These screen shots are on Windows10.

glfw_opengl3

alt

glfw_opengl3_iconfont_viewer

alt

glfw_opengl3_image_load

alt

glfw_opengl3_image_save

alt

glfw_opengl3_nimgl_imguin_jp

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

glfw_opengl3_implot

Showing ImGui demo with ImPlot demo.
alt
alt

glfw_opengl3_imnodes

alt

glfw_opengl3_imguizmo

alt

My test app movie using imguin

Sample movie,Youtube

Update / Downgrade Dear ImGui and CImGui

Prerequisite


  1. Git installed.

  2. Installed MSys2/MinGW command line tools (Unix tools), make, cp, rm, ...etc

  3. Windows10 or later Clang/LLVM refer to Futhark installation.

    nimble install futhark

    It must exist libclang.a file in the library path (e.g. in c:\llvm\lib).

  4. Linux Debian 12 Bookworm

    sudo apt install  clang-16
    nimble install --passL:"-L/usr/lib/llvm-16/lib" futhark

Important Notice: Confirm Futhark version is v0.13.6 at this time. (2024/09)

nimble dump futhark

name: "futhark"
version: "0.13.6"
author: "PMunch"
desc: "A package which uses libclang to parse C headers into Nim files for easy interop"
license: "MIT"
...

Update / Downgrade ImGui/CImGui


  1. Compose development folders
    First move to your working folder you like, then

    mkdir imguin_dev
    cd imguin_dev
    git clone https://github.com/dinau/imguin
    cd imguin
  2. Clone ImGui/CImGui etc. sources at once forever

    pwd
    imguin
    make clonelibs

    Cloned libraries are under ../libs/ folder

  3. Recursively update the sources using git Pull or fetch command in the each library folder,
    ../libs/cimgui
    ../libs/cimguizmo
    ../libs/cimnodes
    ../libs/cimplot

  4. Checkout arbitrary version with git command in the respective folder

  5. Specify your Clang include path to ClangIncludePath in imguin/src/imguin/cimgui.nim.

  6. Generate the definition file uisng Futhark,

    pwd
    imguin
    make gen
  7. Install updated files
    Properly edit the version info etc in imguin.nimble file, then

    pwd
    imguin
    nimble uninstall imguin  # Remove old versions if it exist. 
    nimble install 

    That's all.
    Repeat from 3. if you'd like to update or downgrade to other version.

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 examples/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. examples/sdl2_opengl3 (2023/03)
    • First step is done. (2023/03)

Compressing binary file


Install UPX with MSys console on WindowsOS,

pacman -S mingw-w64-ucrt-x86_64-upx

For instance,

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)

Lnux Mint 22

Other link


Similar project


Language Binding Project
Nim CImGui/CImPlot ImGuin, Nimgl_test, Nim_implot
Lua CImGui/CImPlot etc. LuaJITImGui
Zig, C lang. Dear bindings Dear_Bindings_Build
Zig CImGui/CImPlot ImGuinZ
Python ImGui direct DearPyGui for 32bit WindowsOS Binary

Star History Chart