Giter VIP home page Giter VIP logo

cimgui's Introduction

cimgui Build Status

This is a thin c-api wrapper programmatically generated for the excellent C++ immediate mode gui Dear ImGui. All imgui.h functions are programmatically wrapped. Generated files are: cimgui.cpp, cimgui.h for C compilation. Also for helping in bindings creation, definitions.lua with function definition information and structs_and_enums.lua. This library is intended as a intermediate layer to be able to use Dear ImGui from other languages that can interface with C (like D - see D-binding)

History:

Initially cimgui was developed by Stephan Dilly as hand-written code but lately turned into an auto-generated version by sonoro1234 in order to keep up with imgui more easily (letting the user select the desired branch and commit)

Notes:

compilation

  • clone

    • git clone --recursive https://github.com/cimgui/cimgui.git
    • git submodule update --init --recursive (If already cloned)
  • compile

    • using makefile on linux/macOS/mingw (Or use CMake to generate project)
    • cmake options are IMGUI_STATIC (compiling as static library), IMGUI_FREETYPE (for using Freetype2) and FREETYPE_PATH (Freetype2 cmake install location) (only if cimgui is generated with freetype option)
    • or as in https://github.com/sonoro1234/LuaJIT-ImGui/tree/master/build

    For compiling with backends there are now examples with SDL2 and opengl3/vulkan in folder backend_test. They'll generate a cimgui_sdl module and a test_sdl executable.

using generator

  • this is only needed (before compilation) if you want an imgui version different from the one provided, otherwise generation is already done.
  • you will need LuaJIT (https://github.com/LuaJIT/LuaJIT.git better 2.1 branch) or precompiled for linux/macOS/windows in https://luapower.com/luajit/download
  • you need to use also a C++ compiler for doing preprocessing: gcc (In windows MinGW-W64-builds for example), clang or cl (MSVC). (this repo was done with gcc)
  • update imgui folder to the version you desire.
  • edit generator/generator.bat on windows, or generator/generator.sh on linux, to choose between gcc, clang, or cl and to choose desired backends and whether imgui_internal is generated or not, Freetype2 is used or not and comments are generated or not
  • the defaults of generator are gcc as compiler, imgui_internal included and sdl, glfw, vulkan, opengl2 and opengl3 as backends.
  • edit config_generator.lua for adding includes needed by your chosen backends (vulkan needs that).
  • Run generator.bat or generator.sh with gcc, clang or cl and LuaJIT on your PATH.
  • as a result some files are generated: cimgui.cpp, cimgui.h and cimgui_impl.h for compiling and some lua/json files with information about the binding: definitions.json with function info, structs_and_enums.json with struct and enum info, impl_definitions.json with functions from the backends info.
  • You can pass compiler flags to generator.sh or generator.bat by editing them at the end of the call to further specify the compiler behavior. (e.g. -DIMGUI_USER_CONFIG or -DIMGUI_USE_WCHAR32)
  • You are able to pass any extra argument to generator.sh (.bat) in the command-line.
  • If you are using different options than cimgui repo and if you want to keep them after a cimgui update, you can keep them in a copy of generator.sh (.bat) outside of cimgui folder where cd cimgui/generator is used before luajit call. See #232 (comment)

generate binding

definitions description

  • It is a collection in which key is the cimgui name that would result without overloadings and the value is an array of overloadings (may be only one overloading)
  • Each overloading is a collection. Some relevant keys and values are:
    • stname : the name of the struct the function belongs to (will be "" if it is top level in ImGui namespace)
    • ov_cimguiname : the overloaded cimgui name (if absent it would be taken from cimguiname)
    • cimguiname : the name without overloading (this should be used if there is not ov_cimguiname)
    • ret : the return type
    • retref : is set if original return type is a reference. (will be a pointer in cimgui)
    • argsT : an array of collections (each one with type: argument type and name: the argument name, when the argument is a function pointer also ret: return type and signature: the function signature)
    • args : a string of argsT concatenated and separated by commas
    • call_args : a string with the argument names separated by commas for calling imgui function
    • defaults : a collection in which key is argument name and value is the default value.
    • manual : will be true if this function is hand-written (not generated)
    • skipped : will be true if this function is not generated (and not hand-written)
    • isvararg : is set if some argument is a vararg
    • constructor : is set if the function is a constructor for a class.
    • destructor : is set if the function is a destructor for a class but not just a default destructor.
    • realdestructor : is set if the function is a destructor for a class
    • templated : is set if the function belongs to a templated class (ImVector)
    • templatedgen: is set if the function belongs to a struct generated from template (ImVector_ImWchar)
    • nonUDT : if present the original function was returning a user defined type so that signature has been changed to accept a pointer to the UDT as first argument.
    • location : name of the header file and linenumber this function comes from. (imgui:000, internal:123, imgui_impl_xxx:123)
    • is_static_function : is setted when it is an struct static function.

structs_and_enums description

  • Is is a collection with three items:
    • under key enums we get the enums collection in which each key is the enum tagname and the value is an array of the ordered values represented as a collection with keys
      • name : the name of this enum value
      • value : the C string
      • calc_value : the numeric value corresponding to value
    • under key structs we get the structs collection in which the key is the struct name and the value is an array of the struct members. Each one given as a collection with keys
      • type : the type of the struct member
      • template_type : if type has a template argument (as ImVector) here will be
      • name : the name of the struct member
      • size : the number of array elements (when it is an array)
      • bitfield : the bitfield width (in case it is a bitfield)
    • under key locations we get the locations collection in which each key is the enum tagname or the struct name and the value is the name of the header file and line number this comes from.

usage

  • use whatever method is in ImGui c++ namespace in the original imgui.h by prepending ig
  • methods have the same parameter list and return values (where possible)
  • functions that belong to a struct have an extra first argument with a pointer to the struct.
  • where a function returns UDT (user defined type) by value some compilers complain so the function is generated accepting a pointer to the UDT type as the first argument (or second if belongs to a struct).

usage with backends

example bindings based on cimgui

C examples based on cimgui

cimgui's People

Contributors

aodq avatar barrybingo avatar dpethes avatar fmdkdd avatar frink avatar gekkio avatar grimmaple avatar gucio321 avatar khanknyo avatar kukkimonsuta avatar lmariscal avatar mellinoe avatar merwaaan avatar mrcsnm avatar nucular avatar okuoku avatar oprypin avatar rokups avatar s-ol avatar sand3r- avatar seafork avatar sonoro1234 avatar the-fyp avatar tversteeg avatar waywardmonkeys avatar wizzard033 avatar xegoist avatar xyene avatar yannick avatar yosikawa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cimgui's Issues

forks

Hi,

I would like to add methods for getting struct variables in a ffi binding.
I am not shure about what should be my base for forking because I have seen different forks adding methods without merging then to a main master.
How should I procced?
@nucular @extrawurst @Gekkio
Best
victor bombi

Compiling with GLEW support

After much frustration and research, I've gotten the code to compile into a DLL/.so, which also includes compiling in the OpenGL/GLFW implementation code in the examples/ directory.

I'm not sure if the issue I'm having will be something that can be addressed here, or if it's left up to the coder.

I digress.

When I build the DLL, I'm linking in my compiled glew.o so that the DLL knows about the GLEW symbols. However, when I try to use the DLL, the glewInit() function is never called from within the DLL, so it never initializes the OpenGL/GLEW stuff, and things like glCreateShader() are ultimately NULL, which causes epic segfaults.

I looked around for a function that could be called to initialize GLEW from within the DLL, but did not find one. Rather than writing a function in CIMGUI to do this (since 1) I really don't think this is in the realm of the CIMGUI lib's intended scope, and 2) I don't want to have to do it every time I ugprade CIMGUI), I instead decided to compile the CIMGUI code directly into my binary.

For one, I really don't want the bloat of CIMGUI directly in my binary. Since CIMGUI makes calls that inlcude imgui_demo.cpp, there is a large amount of bloat. Again, I don't want to have to modify the CIMGUI code every time it's upgraded to remove the calls to the demo code to shrink the code base.

For two, if GLEW is going to be supported it should have some mechanism to initalize it from within a DLL/.so.

I have not used, nor do I intend to, GL3W or GLAD. To that end, I do not know if this is an issue that is specific to GLEW that I will simply have to work around. Any help with this would be greatly appreciated.

My main issue with CIMGUI at this point is this: it's use cases are extremely dependent upon your coding style. I've looked at your LuaJIT-cimgui to figure out how to build the DLL/.so that includes the implementations, and it seems highly specific to a single use case. I realize that you primarily use CIMGUI for your own uses, but when you say "look at X project for examples", said projects don't lend themselves to being very informative either.

In saying that, if I can find the time, I will try to improve the docs to provide some examples of general use cases. And, if I can come up with an acceptable method of building a DLL/.so that can initialize GLEW without requiring mods to CIMGUI itself, I will provide it as well. Same goes for stripping out the code from imgui_demo.cpp (for when you don't need it in production).

Now that I've spent some time figuring out how to use CIMGUI I do enjoy using it. I just think the docs need some polishing and the focus of the project needs to be expanded slightly to be more "general use" in nature.

ImDrawIdx declaration

@ocornut

ideally

#ifndef ImDrawIdx
typedef unsigned short ImDrawIdx;
#endif

should be moved before ImVector declaration in imgui.h so that when I declare
ImVector_ImDrawIdx for ImVector<ImDrawIdx>
ImDrawIdx is already declared

Now I can make it work with the trick of programatically moving this declarations but I think that the other way would be cleaner
Dont you?

ImFontConfig constructor missing?

It appears that the default constructor for ImFontConfig has no C wrapper. Some of the values are not zero by default, so a simple clear of an ImFontConfig object is not enough.

compiling

Hi,

` git clone https://github.com/Extrawurst/cimgui
Cloning into 'cimgui'...
remote: Counting objects: 489, done.
remote: Total 489 (delta 0), reused 0 (delta 0), pack-reused 489
Receiving objects: 100% (489/489), 444.41 KiB | 290.00 KiB/s, done.
Resolving deltas: 100% (325/325), done.
Checking connectivity... done.

a@zelman:~$ cd cimgui

a@zelman:~/cimgui$ ls
cimgui imgui LICENSE menus-api.gif README.md screenshot.png

a@zelman:~/cimgui$ cd cimgui

a@zelman:~/cimgui/cimgui$ ls
cimgui.cpp cimgui.sln cimgui.vcxproj.filters fontAtlas.cpp Makefile
cimgui.h cimgui.vcxproj drawList.cpp listClipper.cpp test.c

a@zelman:~/cimgui/cimgui$ make

g++ -I../../ -Wall -shared -fPIC -c -o cimgui.o cimgui.cpp
cimgui.cpp:2:28: fatal error: ../imgui/imgui.h: No such file or directory
compilation terminated.
Makefile:48: polecenia dla obiektu 'cimgui.o' nie powiodły się
make: *** [cimgui.o] Błąd 1
`
My system
Ubuntu 16.04 LTS

ImGui 1.60

Hi,

I am working on ImGui 1.60. I think it would be good to share it but in a different branch.
@extrawurst What do you think about it?

Best Regards
victor bombi

Don't generated minimized JSON files

The json output are minimized (no carriage return, no space) which:

  • makes them hard to humanly read (if someone wants to study their structure for parsing)
  • hard to patch, hard to follow changes
  • makes the git commits very large

I feel this is necessary and the output ,json files should be nicely idented like the LUA files are.

C example

Hello,

Can you make ANSI C example for this binding?

Redefinition of 'TextRange' on macOS

It seems that Apple defines a TextRange struct in AE/AERegistry.h (AppleEvents Registry Interface). Renaming the TextRange struct to ImTextRange fixes the issue. If you would like a PR for the change let me know and I'll get one to you.

ImVector question (new ImVector Branch)

I'm following the demos from imgui_demo.cpp, and the log window is giving me some fits.
I've figured out how to handle ImGuiTextBuffer and ImGuiTextFilter in C code. But ImVector is giving me all kinds of hell.
Am I missing some functionality, or am I assuming correctly that the note about ImVector from the readme should tell me that handling of ImVector is incomplete?
Specifically, I am looking at this line of code.
If ImVector isn't suitable for use without doing something similar to ImVector_ImWchar I can work around it. I just want to be sure I'm not missing some functionality somewhere in the code. (Though I'm 99% certain it's not there.)

entry point not found when using cimgui.dylib from docking branch

Hi, Im trying to build cimgui with dear imgui docking branch, followed the compile instructions with cmake to generate unix makefile and run make in osx terminal.
It spits out cimgui.dylib, however, when I tried to call some docking related functions e.g. igIsWindowDocked or igSetNextWindowDockID, i get entry point not found exception (im using ImGui.NET wrapper for my project).

I tried to dump dylib entry points:
cimgui_entries.txt

and it looks like some functions has prefix like _ZXX, I think I missed out something when generating the makefile, im still wondering what the issue is, please kindly advise.

and perhaps the build instructions can be improved, so as to make it clearer on how to generate correct output (particularly when building from other branch than master)?

FLT_MAX changes with preprocessor

@mellinoe or others interested

The value of FLT_MAX constant changes with preprocesor (and may be the compiler also)

It affects to definitions.lua changing the defaults values.
see: #65 (comment)

My proposal is to replace the value (some number) by "FLT_MAX" in definitions.lua
When implementing the binding you can use igGET_FLT_MAX() function to get the actual value of this constant according to your compiler

It is in branch FLT_MAX or PR #68
Already in master.

nocompiler option already outputs FLT_MAX

This issue is only not solved for cl. If someone needs it could be solved getting FLT_MAX from definitions.json

Cannot generate GLFW and OpenGL3 bindings

OS

Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic

Linux HOST 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

I am trying to compile cimgui on the above system. I have tried cloning from github as well as downloading the ZIP files and extracting manually.

The problem(s) I'm having are coming from the generator. When I try to get the GLFW and OpenGL 3 bindings, I'm getting all sorts of errors. It does not matter if I try to use the standard Makefile or cmake. I've read previous issues and tried using examples from luajit-imgui and various other sources found via Google, but nothing seems to work. I get errors when trying to use gcc or "nocompiler" with the generator.

EDIT: My project is using C99.

Here is the output from cloning into a clean directory and using make:

USER@HOST:~/PROJECT/deps$ git clone --recursive https://github.com/cimgui/cimgui.git
Cloning into 'cimgui'...
remote: Enumerating objects: 133, done.
remote: Counting objects: 100% (133/133), done.
remote: Compressing objects: 100% (62/62), done.
remote: Total 1503 (delta 82), reused 102 (delta 70), pack-reused 1370
Receiving objects: 100% (1503/1503), 1.85 MiB | 1.05 MiB/s, done.
Resolving deltas: 100% (1032/1032), done.
Submodule 'imgui' (https://github.com/ocornut/imgui.git) registered for path 'imgui'
Cloning into '/home/USER/PROJECT/deps/cimgui/imgui'...
remote: Enumerating objects: 40, done.        
remote: Counting objects: 100% (40/40), done.        
remote: Compressing objects: 100% (23/23), done.        
remote: Total 26478 (delta 21), reused 28 (delta 17), pack-reused 26438        
Receiving objects: 100% (26478/26478), 32.51 MiB | 3.19 MiB/s, done.
Resolving deltas: 100% (19549/19549), done.
Submodule path 'imgui': checked out '7a5058e3bfea4149acef2ad98d8fdd62605a0f4c'
USER@HOST:~/PROJECT/deps$ cd cimgui/
USER@HOST:~/PROJECT/deps/cimgui$ make
g++ -O2 -I./imgui/ -Wall -shared -fPIC -c -o cimgui.o cimgui.cpp
g++ -O2 -I./imgui/ -Wall -shared -fPIC -c -o imgui/imgui.o imgui/imgui.cpp
g++ -O2 -I./imgui/ -Wall -shared -fPIC -c -o imgui/imgui_draw.o imgui/imgui_draw.cpp
g++ -O2 -I./imgui/ -Wall -shared -fPIC -c -o imgui/imgui_demo.o imgui/imgui_demo.cpp
g++ -O2 -I./imgui/ -Wall -shared -fPIC -c -o imgui/imgui_widgets.o imgui/imgui_widgets.cpp
g++ -o cimgui.so cimgui.o ./imgui/imgui.o ./imgui/imgui_draw.o ./imgui/imgui_demo.o ./imgui/imgui_widgets.o -O2 -I./imgui/ -Wall -shared -fPIC 
Build complete for Linux
USER@HOST:~/PROJECT/deps/cimgui$ 
USER@HOST:~/PROJECT/deps/cimgui$ cd generator/
USER@HOST:~/PROJECT/deps/cimgui/generator$ luajit generator.lua gcc glfw opengl3
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


HAVE_COMPILER	true
IMGUI_VERSION	"1.67"
------------------generation with gcc------------------------
../imgui/imgui.h:27:9: warning: #pragma once in main file
 #pragma once
         ^~~~
-----------------check arg detection---------------------------
-----------------end check arg detection-----------------------
luajit: generator.lua:964: enum in struct
stack traceback:
	[C]: in function 'assert'
	generator.lua:964: in function 'gen_structs_and_enums_table'
	generator.lua:1573: in main chunk
	[C]: at 0x5653b82f41d0
USER@HOST:~/PROJECT/deps/cimgui/generator$ luajit generator.lua nocompiler glfw opengl3
Working without compiler 
HAVE_COMPILER	false
IMGUI_VERSION	"1.67"
------------------generation with nocompiler------------------------
-----------------check arg detection---------------------------
-----------------end check arg detection-----------------------
luajit: generator.lua:1596: could not get file: ../imgui/examples/imgui_impl_glfw.h : No such file or directory
stack traceback:
	[C]: in function 'error'
	generator.lua:1596: in main chunk
	[C]: at 0x55c144c0a1d0
USER@HOST:~/PROJECT/deps/cimgui/generator$ ls -l ../imgui/examples/
total 444
drwxr-xr-x 2 USER USER  4096 Jan 26 10:07 example_allegro5
drwxr-xr-x 6 USER USER  4096 Jan 26 10:07 example_apple_metal
drwxr-xr-x 3 USER USER  4096 Jan 26 10:07 example_apple_opengl2
drwxr-xr-x 2 USER USER  4096 Jan 26 10:07 example_freeglut_opengl2
drwxr-xr-x 2 USER USER  4096 Jan 26 10:07 example_glfw_opengl2
drwxr-xr-x 2 USER USER  4096 Jan 26 10:07 example_glfw_opengl3
drwxr-xr-x 2 USER USER  4096 Jan 26 10:07 example_glfw_vulkan
drwxr-xr-x 3 USER USER  4096 Jan 26 10:07 example_marmalade
drwxr-xr-x 2 USER USER  4096 Jan 26 10:07 example_null
drwxr-xr-x 2 USER USER  4096 Jan 26 10:07 example_sdl_opengl2
drwxr-xr-x 2 USER USER  4096 Jan 26 10:07 example_sdl_opengl3
drwxr-xr-x 2 USER USER  4096 Jan 26 10:07 example_sdl_vulkan
drwxr-xr-x 2 USER USER  4096 Jan 26 10:07 example_win32_directx10
drwxr-xr-x 2 USER USER  4096 Jan 26 10:07 example_win32_directx11
drwxr-xr-x 2 USER USER  4096 Jan 26 10:07 example_win32_directx12
drwxr-xr-x 2 USER USER  4096 Jan 26 10:07 example_win32_directx9
-rw-r--r-- 1 USER USER  4510 Jan 26 10:07 imgui_examples.sln
-rw-r--r-- 1 USER USER 16306 Jan 26 10:07 imgui_impl_allegro5.cpp
-rw-r--r-- 1 USER USER  1583 Jan 26 10:07 imgui_impl_allegro5.h
-rw-r--r-- 1 USER USER 22563 Jan 26 10:07 imgui_impl_dx10.cpp
-rw-r--r-- 1 USER USER  1017 Jan 26 10:07 imgui_impl_dx10.h
-rw-r--r-- 1 USER USER 23677 Jan 26 10:07 imgui_impl_dx11.cpp
-rw-r--r-- 1 USER USER  1082 Jan 26 10:07 imgui_impl_dx11.h
-rw-r--r-- 1 USER USER 27598 Jan 26 10:07 imgui_impl_dx12.cpp
-rw-r--r-- 1 USER USER  1963 Jan 26 10:07 imgui_impl_dx12.h
-rw-r--r-- 1 USER USER 11968 Jan 26 10:07 imgui_impl_dx9.cpp
-rw-r--r-- 1 USER USER  1011 Jan 26 10:07 imgui_impl_dx9.h
-rw-r--r-- 1 USER USER  6709 Jan 26 10:07 imgui_impl_freeglut.cpp
-rw-r--r-- 1 USER USER  2018 Jan 26 10:07 imgui_impl_freeglut.h
-rw-r--r-- 1 USER USER 15254 Jan 26 10:07 imgui_impl_glfw.cpp
-rw-r--r-- 1 USER USER  2198 Jan 26 10:07 imgui_impl_glfw.h
-rw-r--r-- 1 USER USER 11899 Jan 26 10:07 imgui_impl_marmalade.cpp
-rw-r--r-- 1 USER USER  1481 Jan 26 10:07 imgui_impl_marmalade.h
-rw-r--r-- 1 USER USER  1378 Jan 26 10:07 imgui_impl_metal.h
-rw-r--r-- 1 USER USER 22057 Jan 26 10:07 imgui_impl_metal.mm
-rw-r--r-- 1 USER USER 10314 Jan 26 10:07 imgui_impl_opengl2.cpp
-rw-r--r-- 1 USER USER  1788 Jan 26 10:07 imgui_impl_opengl2.h
-rw-r--r-- 1 USER USER 24435 Jan 26 10:07 imgui_impl_opengl3.cpp
-rw-r--r-- 1 USER USER  2487 Jan 26 10:07 imgui_impl_opengl3.h
-rw-r--r-- 1 USER USER   805 Jan 26 10:07 imgui_impl_osx.h
-rw-r--r-- 1 USER USER  9284 Jan 26 10:07 imgui_impl_osx.mm
-rw-r--r-- 1 USER USER 13905 Jan 26 10:07 imgui_impl_sdl.cpp
-rw-r--r-- 1 USER USER  1619 Jan 26 10:07 imgui_impl_sdl.h
-rw-r--r-- 1 USER USER 52353 Jan 26 10:07 imgui_impl_vulkan.cpp
-rw-r--r-- 1 USER USER  5690 Jan 26 10:07 imgui_impl_vulkan.h
-rw-r--r-- 1 USER USER 10932 Jan 26 10:07 imgui_impl_win32.cpp
-rw-r--r-- 1 USER USER  1279 Jan 26 10:07 imgui_impl_win32.h
drwxr-xr-x 5 USER USER  4096 Jan 26 10:07 libs
-rw-r--r-- 1 USER USER 12130 Jan 26 10:07 README.txt

And here is the output from cloning into a clean directory and using cmake:

USER@HOST:~/PROJECT/deps$ git clone --recursive https://github.com/cimgui/cimgui.git
Cloning into 'cimgui'...
remote: Enumerating objects: 133, done.
remote: Counting objects: 100% (133/133), done.
remote: Compressing objects: 100% (62/62), done.
remote: Total 1503 (delta 82), reused 102 (delta 70), pack-reused 1370
Receiving objects: 100% (1503/1503), 1.85 MiB | 334.00 KiB/s, done.
Resolving deltas: 100% (1032/1032), done.
Submodule 'imgui' (https://github.com/ocornut/imgui.git) registered for path 'imgui'
Cloning into '/home/USER/PROJECT/deps/cimgui/imgui'...
remote: Enumerating objects: 40, done.        
remote: Counting objects: 100% (40/40), done.        
remote: Compressing objects: 100% (23/23), done.        
remote: Total 26478 (delta 21), reused 28 (delta 17), pack-reused 26438        
Receiving objects: 100% (26478/26478), 32.51 MiB | 2.26 MiB/s, done.
Resolving deltas: 100% (19549/19549), done.
Submodule path 'imgui': checked out '7a5058e3bfea4149acef2ad98d8fdd62605a0f4c'
USER@HOST:~/PROJECT/deps/cimgui$ cmake -DCMAKE_INSTALL_PREFIX=/home/USER/PROJECT/build/linux/x86_64/client/debug/lib -DIMPL_GLFW=yes -DIMPL_OPENGL3=yes -DCMAKE_BUILD_TYPE=RelWithDebInfo .
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    IMPL_GLFW
    IMPL_OPENGL3


-- Build files have been written to: /home/USER/PROJECT/deps/cimgui
USER@HOST:~/PROJECT/deps/cimgui$ make
Scanning dependencies of target cimgui
[ 16%] Building CXX object CMakeFiles/cimgui.dir/cimgui.cpp.o
[ 33%] Building CXX object CMakeFiles/cimgui.dir/imgui/imgui.cpp.o
[ 50%] Building CXX object CMakeFiles/cimgui.dir/imgui/imgui_draw.cpp.o
[ 66%] Building CXX object CMakeFiles/cimgui.dir/imgui/imgui_demo.cpp.o
[ 83%] Building CXX object CMakeFiles/cimgui.dir/imgui/imgui_widgets.cpp.o
[100%] Linking CXX shared library cimgui.so
[100%] Built target cimgui
USER@HOST:~/PROJECT/deps/cimgui$ cd generator/
USER@HOST:~/PROJECT/deps/cimgui/generator$ luajit generator.lua gcc glfw opengl3
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


HAVE_COMPILER	true
IMGUI_VERSION	"1.67"
------------------generation with gcc------------------------
../imgui/imgui.h:27:9: warning: #pragma once in main file
 #pragma once
         ^~~~
-----------------check arg detection---------------------------
-----------------end check arg detection-----------------------
luajit: generator.lua:964: enum in struct
stack traceback:
	[C]: in function 'assert'
	generator.lua:964: in function 'gen_structs_and_enums_table'
	generator.lua:1573: in main chunk
	[C]: at 0x55ba8e2711d0
USER@HOST:~/PROJECT/deps/cimgui/generator$ luajit generator.lua nocompiler glfw opengl3
Working without compiler 
HAVE_COMPILER	false
IMGUI_VERSION	"1.67"
------------------generation with nocompiler------------------------
-----------------check arg detection---------------------------
-----------------end check arg detection-----------------------
luajit: generator.lua:1596: could not get file: ../imgui/examples/imgui_impl_glfw.h : No such file or directory
stack traceback:
	[C]: in function 'error'
	generator.lua:1596: in main chunk
	[C]: at 0x558552cae1d0
USER@HOST:~/PROJECT/deps/cimgui/generator$ ls -l ../imgui/examples/
total 444
drwxr-xr-x 2 USER USER  4096 Jan 26 10:20 example_allegro5
drwxr-xr-x 6 USER USER  4096 Jan 26 10:20 example_apple_metal
drwxr-xr-x 3 USER USER  4096 Jan 26 10:20 example_apple_opengl2
drwxr-xr-x 2 USER USER  4096 Jan 26 10:20 example_freeglut_opengl2
drwxr-xr-x 2 USER USER  4096 Jan 26 10:20 example_glfw_opengl2
drwxr-xr-x 2 USER USER  4096 Jan 26 10:20 example_glfw_opengl3
drwxr-xr-x 2 USER USER  4096 Jan 26 10:20 example_glfw_vulkan
drwxr-xr-x 3 USER USER  4096 Jan 26 10:20 example_marmalade
drwxr-xr-x 2 USER USER  4096 Jan 26 10:20 example_null
drwxr-xr-x 2 USER USER  4096 Jan 26 10:20 example_sdl_opengl2
drwxr-xr-x 2 USER USER  4096 Jan 26 10:20 example_sdl_opengl3
drwxr-xr-x 2 USER USER  4096 Jan 26 10:20 example_sdl_vulkan
drwxr-xr-x 2 USER USER  4096 Jan 26 10:20 example_win32_directx10
drwxr-xr-x 2 USER USER  4096 Jan 26 10:20 example_win32_directx11
drwxr-xr-x 2 USER USER  4096 Jan 26 10:20 example_win32_directx12
drwxr-xr-x 2 USER USER  4096 Jan 26 10:20 example_win32_directx9
-rw-r--r-- 1 USER USER  4510 Jan 26 10:20 imgui_examples.sln
-rw-r--r-- 1 USER USER 16306 Jan 26 10:20 imgui_impl_allegro5.cpp
-rw-r--r-- 1 USER USER  1583 Jan 26 10:20 imgui_impl_allegro5.h
-rw-r--r-- 1 USER USER 22563 Jan 26 10:20 imgui_impl_dx10.cpp
-rw-r--r-- 1 USER USER  1017 Jan 26 10:20 imgui_impl_dx10.h
-rw-r--r-- 1 USER USER 23677 Jan 26 10:20 imgui_impl_dx11.cpp
-rw-r--r-- 1 USER USER  1082 Jan 26 10:20 imgui_impl_dx11.h
-rw-r--r-- 1 USER USER 27598 Jan 26 10:20 imgui_impl_dx12.cpp
-rw-r--r-- 1 USER USER  1963 Jan 26 10:20 imgui_impl_dx12.h
-rw-r--r-- 1 USER USER 11968 Jan 26 10:20 imgui_impl_dx9.cpp
-rw-r--r-- 1 USER USER  1011 Jan 26 10:20 imgui_impl_dx9.h
-rw-r--r-- 1 USER USER  6709 Jan 26 10:20 imgui_impl_freeglut.cpp
-rw-r--r-- 1 USER USER  2018 Jan 26 10:20 imgui_impl_freeglut.h
-rw-r--r-- 1 USER USER 15254 Jan 26 10:20 imgui_impl_glfw.cpp
-rw-r--r-- 1 USER USER  2198 Jan 26 10:20 imgui_impl_glfw.h
-rw-r--r-- 1 USER USER 11899 Jan 26 10:20 imgui_impl_marmalade.cpp
-rw-r--r-- 1 USER USER  1481 Jan 26 10:20 imgui_impl_marmalade.h
-rw-r--r-- 1 USER USER  1378 Jan 26 10:20 imgui_impl_metal.h
-rw-r--r-- 1 USER USER 22057 Jan 26 10:20 imgui_impl_metal.mm
-rw-r--r-- 1 USER USER 10314 Jan 26 10:20 imgui_impl_opengl2.cpp
-rw-r--r-- 1 USER USER  1788 Jan 26 10:20 imgui_impl_opengl2.h
-rw-r--r-- 1 USER USER 24435 Jan 26 10:20 imgui_impl_opengl3.cpp
-rw-r--r-- 1 USER USER  2487 Jan 26 10:20 imgui_impl_opengl3.h
-rw-r--r-- 1 USER USER   805 Jan 26 10:20 imgui_impl_osx.h
-rw-r--r-- 1 USER USER  9284 Jan 26 10:20 imgui_impl_osx.mm
-rw-r--r-- 1 USER USER 13905 Jan 26 10:20 imgui_impl_sdl.cpp
-rw-r--r-- 1 USER USER  1619 Jan 26 10:20 imgui_impl_sdl.h
-rw-r--r-- 1 USER USER 52353 Jan 26 10:20 imgui_impl_vulkan.cpp
-rw-r--r-- 1 USER USER  5690 Jan 26 10:20 imgui_impl_vulkan.h
-rw-r--r-- 1 USER USER 10932 Jan 26 10:20 imgui_impl_win32.cpp
-rw-r--r-- 1 USER USER  1279 Jan 26 10:20 imgui_impl_win32.h
drwxr-xr-x 5 USER USER  4096 Jan 26 10:20 libs
-rw-r--r-- 1 USER USER 12130 Jan 26 10:20 README.txt

Even running the generator first produces the same errors as above.

I simply want to build the cimgui library as a .so (or .dll on Windows via MSYS2/MinGW-64, though I'm primarilly interested in getting this to compile on Linux first) that I can link against. My project uses a custom configure script and Makefile, but it's standard stuff. Ideally, my configure script should check to see if libcimgui.so (or whatever it ends up being called) is built and if not, clone/extract the sources (if necessary) and run the appropriate build steps to obtain the library.

All that aside. I have only a passing knowledge of LUA, but looking at the generator source I don't see anything obvious. And I most certainly know the file it's looking for is exactly where it should be. What the hell am I overlooking?

(NOTE: Due to strict versioning requirements for this project, I'd really prefer to use https://github.com/cimgui/cimgui/archive/1.66b.1.zip and https://github.com/ocornut/imgui/archive/v1.67.zip as the sources for the project. I realize these two targets are under active development and on the move, but this requirement is out of my hands. It's agravating. If later on I need to update the sources I will, but using the git repo directly is a no-go for this project. Gotta love anal project managers.)

Usage question

This is not really an issue, but me not knowing exactly how to use the C-wrapper. A noob issue.
I get that you compile the project using a C++ compiler and you export the functions to C and link against them.
The problem I have is using the types. cimgui.h only has forward-declarations, so I cannot set inner properties of ImGuiIO.
I looked at your D-binding and you have a header that defines the types to be used.
Do I need to do that here? If so, I wonder why that header is not already included. I feel that I am missing something.

Thanks!

Update to imgui 1.51

imgui 1.51 has just been released, and I'd appreciate it if you updated this library to use imgui 1.51.
Thanks!

Instructions

I think the instructions could be improved to be super explicit

  • "clone" -> "show git cloning command-line" (include recursive remote)
  • "make using..." -> "command-line for Windows, for Mac etc."
  • explicit instructions to download and build luajit

Etc.
all those steps being super explicit would make a difference in adoption ihmo.

I am still trying to figure the steps for Windows and the generator is spitting out

HAVE_GCC        true
failure arg detection   BeginTabItem    nil     nil     (const char* label,bool* p_open,ImGuiTabItemFlags)      ImGuiTabItemFlags
reference to no const arg in    ColorConvertRGBtoHSV    (float r,float g,float b,float& out_h,float& out_s,float& out_v)
reference to no const arg in    ColorConvertRGBtoHSV    (float r,float g,float b,float& out_h,float& out_s,float& out_v)
reference to no const arg in    ColorConvertRGBtoHSV    (float r,float g,float b,float& out_h,float& out_s,float& out_v)
reference to no const arg in    ColorConvertHSVtoRGB    (float h,float s,float v,float& out_r,float& out_g,float& out_b)
reference to no const arg in    ColorConvertHSVtoRGB    (float h,float s,float v,float& out_r,float& out_g,float& out_b)
reference to no const arg in    ColorConvertHSVtoRGB    (float h,float s,float v,float& out_r,float& out_g,float& out_b)
../imgui/imgui.h:9:9: warning: #pragma once in main file
 #pragma once
         ^~~~
failure arg detection   return  nil     nil     (&x)    &x
reference to no const arg in    return  (&x)
failure arg detection   return  nil     nil     (&x)    &x
reference to no const arg in    return  (&x)
-----------------check arg detection---------------------------
bad argument name       nil     in      return  (x)
bad argument name       nil     in      return  (x)
-----------------end check arg detection-----------------------
luajit.exe: ./generator.lua:742: enum in struct
stack traceback:
        [C]: in function 'assert'
        ./generator.lua:742: in function 'gen_structs_and_enums_table'
        ./generator.lua:1234: in main chunk
        [C]: at 0x00d521f0

MSVC: ImNewDummy requires at least one member

On master (4397288) trying to include cimgui.h from a C source file with MSVC and CIMGUI_DEFINE_ENUMS_AND_STRUCTS defined fails with the following error:

c:\[...]\cimgui\cimgui.h(591): error C2016: C requires that a struct or union has at least one member

In this header file ImNewDummy does not seem to be used anywhere?
My current hacky workaround is to define this line before include cimgui.h

#define ImNewDummy __ImNewDummyHack { int dummy; }; static void __ImNewDummyHack__##__FILE__ ()

Thoughts

That's very interesting. I was looking at it just earlier. I think it'd be quite hard to do a satisfying C-wrapper. ImGui relies on default parameters and overloaded functions quite a lot.

How come your cimgui.h has default parameters? Would that compile with raw C ?

At first glance I would suggest
ig_BeginChild2 -> ig_BeginChildEx
ig_SetWindowPos2 -> SetWindowPosByName
ig_PushID(const char* str_id) -> PushIdStr
ig_PushID2(const void* ptr_id) -> PushIdPtr
ig_PushID3(const int int_id) ->PushIdInt
ig_RadioButton -> RadioButtonBool
ig_RadioButton2-> RadioButton

ig_TreeNode(const char* str_label_id); --> TreeNode
ig_TreeNode2(const char* str_id, const char* fmt, ...); -> TreeNodeStr
ig_TreeNode3(const void* ptr_id, const char* fmt, ...); -> TreeNodePtr
ig_TreeNodeV(const char* str_id, const char* fmt, va_list args); --> TreeNodeStrV
ig_TreeNodeV2(const void* ptr_id, const char* fmt, va_list args); --> TreeNodePtrV
ig_TreePush(const char* str_id = NULL); -> TreePushStr
ig_TreePush2(const void* ptr_id = NULL); -> TreePushPtr

Not sure about those yet
ig_Selectable(const char* label, bool selected = false, const ImVec2 size = ImVec2(0, 0)); --> ig_Selectable2(const char* label, bool* p_selected, const ImVec2 size = ImVec2(0, 0)); -->

ig_ListBox(const char* label, int* current_item, const char** items, int items_count, int ig_ListBox2(const char* label, int* current_item, bool(items_getter)(void data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);

ig_Value(const char* prefix, bool b); --> ValueBool,
ig_Value2(const char* prefix, int v); --> ValueInt
ig_Value3(const char* prefix, unsigned int v); --> ValueUint
ig_Value4(const char* prefix, float v, const char* float_format = NULL);-> ValueFloat
etc.

It's a tough nut to crack well.

Why not returning ImVec2?

Hi,

igGetCursorScreenPos for example expects an ImVec2 pointer instead of returning an ImVec2
ImGui expected behaviour can be provided as in code below (which is tedious for the binding writer)

function M.GetCursorScreenPos()
	local pos = ImVec2_p()
	lib.igGetCursorScreenPos(pos)
	return pos[0]
end

Is there any reason for this design?

News: branch master refactor was merged

I have done a refactoring and was just merged.

definitions have been changed so that you dont need to set extra arguments (self as first argument)

for nonUDT variants the pointer to the value to change will be now the first argument (before was second after the struct* self)

structs_and_enums will show the correct C ImVector_xxxx types

ImVector usage

I am most interested in ImVector use cases.
Has anybody been able to use an ImVector not just reading from it but also creating an ImVector before using it?

Also, to really expose it as a C interface we should define several new structs as for example

typedef struct ImVector_ImWchar_t
{
int Size;
int Capacity;
ImWchar* Data;
} ImVector_ImWchar;

can't compile on os x

i'm getting the following error when linking.

c++ -I/usr/local/include -Wall -c -o cimgui.o cimgui.cpp
c++ -I/usr/local/include -Wall -c -o fontAtlas.o fontAtlas.cpp
c++ -I/usr/local/include -Wall -c -o drawList.o drawList.cpp
c++ -I/usr/local/include -Wall -c -o ../imgui/imgui.o ../imgui/imgui.cpp
c++ -o cimgui.dylib cimgui.o fontAtlas.o  drawList.o ../imgui/imgui.o -I/usr/local/include -Wall -dynamiclib
Undefined symbols for architecture x86_64:
  "ImDrawData::DeIndexAllBuffers()", referenced from:
      _ImDrawData_DeIndexAllBuffers in drawList.o
  "ImDrawList::AddDrawCmd()", referenced from:
      ImGui::NewFrame() in imgui.o
  "ImDrawList::AddPolyline(ImVec2 const*, int, unsigned int, bool, float, bool)", referenced from:
      ImDrawList::PathStroke(unsigned int, bool, float) in imgui.o
  "ImDrawList::PopClipRect()", referenced from:
      PopClipRect() in imgui.o
      ImGui::ShowMetricsWindow(bool*)::Funcs::NodeDrawList(ImDrawList*, char const*) in imgui.o
  "ImDrawList::PopTextureID()", referenced from:
      ImGui::Render() in imgui.o
      ImGui::PopFont() in imgui.o
  "ImDrawList::PushClipRect(ImVec4 const&)", referenced from:
      PushClipRect(ImRect const&, bool) in imgui.o
  "ImDrawList::AddRectFilled(ImVec2 const&, ImVec2 const&, unsigned int, float, int)", referenced from:
      ImGui::RenderFrame(ImVec2, ImVec2, unsigned int, bool, float) in imgui.o
      ImGui::Begin(char const*, bool*, ImVec2 const&, float, int) in imgui.o
      Scrollbar(ImGuiWindow*) in imgui.o
      ImGui::ImageButton(void*, ImVec2 const&, ImVec2 const&, ImVec2 const&, int, ImVec4 const&, ImVec4 const&) in imgui.o
      ImGui::InputTextEx(char const*, char*, int, ImVec2 const&, int, int (*)(ImGuiTextEditCallbackData*), void*) in imgui.o
      ImGui::SliderBehavior(ImRect const&, unsigned int, float*, float, float, float, int, bool) in imgui.o
      ImGui::PlotEx(ImGuiPlotType, char const*, float (*)(void*, int), void*, int, int, char const*, float, float, ImVec2) in imgui.o
      ...
  "ImDrawList::ChannelsMerge(int)", referenced from:
      ImGui::Columns(int, char const*, bool) in imgui.o
  "ImDrawList::ChannelsSplit(int)", referenced from:
      ImGui::Columns(int, char const*, bool) in imgui.o
  "ImDrawList::PathArcToFast(ImVec2 const&, float, int, int)", referenced from:
      ImGui::Begin(char const*, bool*, ImVec2 const&, float, int) in imgui.o
  "ImDrawList::PushTextureID(void* const&)", referenced from:
      ImGui::NewFrame() in imgui.o
      ImGui::Render() in imgui.o
      ImGui::Begin(char const*, bool*, ImVec2 const&, float, int) in imgui.o
      ImGui::PushFont(ImFont*) in imgui.o
  "ImDrawList::AddCircleFilled(ImVec2 const&, float, unsigned int, int)", referenced from:
      CloseWindowButton(bool*) in imgui.o
      ImGui::Bullet() in imgui.o
      ImGui::BulletTextV(char const*, __va_list_tag*) in imgui.o
      ImGui::RadioButton(char const*, bool) in imgui.o
  "ImDrawList::ClearFreeMemory()", referenced from:
      ImGui::Shutdown() in imgui.o
      ImDrawList::~ImDrawList() in imgui.o
  "ImDrawList::AddTriangleFilled(ImVec2 const&, ImVec2 const&, ImVec2 const&, unsigned int)", referenced from:
      ImGui::RenderCollapseTriangle(ImVec2, bool, float, bool) in imgui.o
  "ImDrawList::ChannelsSetCurrent(int)", referenced from:
      ImGui::NextColumn() in imgui.o
  "ImDrawList::AddConvexPolyFilled(ImVec2 const*, int, unsigned int, bool)", referenced from:
      ImDrawList::PathFill(unsigned int) in imgui.o
  "ImDrawList::PushClipRectFullScreen()", referenced from:
      ImGui::NewFrame() in imgui.o
      ImGui::ShowMetricsWindow(bool*)::Funcs::NodeDrawList(ImDrawList*, char const*) in imgui.o
  "ImDrawList::Clear()", referenced from:
      ImGui::NewFrame() in imgui.o
      ImGui::Begin(char const*, bool*, ImVec2 const&, float, int) in imgui.o
      ImDrawList::ImDrawList() in imgui.o
  "ImDrawList::AddLine(ImVec2 const&, ImVec2 const&, unsigned int, float)", referenced from:
      ImGui::Begin(char const*, bool*, ImVec2 const&, float, int) in imgui.o
      CloseWindowButton(bool*) in imgui.o
      ImGui::Columns(int, char const*, bool) in imgui.o
      ImGui::InputTextEx(char const*, char*, int, ImVec2 const&, int, int (*)(ImGuiTextEditCallbackData*), void*) in imgui.o
      ImGui::PlotEx(ImGuiPlotType, char const*, float (*)(void*, int), void*, int, int, char const*, float, float, ImVec2) in imgui.o
      ImGui::Separator() in imgui.o
  "ImDrawList::AddRect(ImVec2 const&, ImVec2 const&, unsigned int, float, int)", referenced from:
      ImGui::RenderFrame(ImVec2, ImVec2, unsigned int, bool, float) in imgui.o
      ImGui::Begin(char const*, bool*, ImVec2 const&, float, int) in imgui.o
      ImGui::Image(void*, ImVec2 const&, ImVec2 const&, ImVec2 const&, ImVec4 const&, ImVec4 const&) in imgui.o
      ImGui::ShowMetricsWindow(bool*)::Funcs::NodeDrawList(ImDrawList*, char const*) in imgui.o
  "ImDrawList::AddText(ImFont const*, float, ImVec2 const&, unsigned int, char const*, char const*, float, ImVec4 const*)", referenced from:
      ImGui::RenderText(ImVec2, char const*, char const*, bool) in imgui.o
      ImGui::RenderTextWrapped(ImVec2, char const*, char const*, float) in imgui.o
      ImGui::RenderTextClipped(ImVec2 const&, ImVec2 const&, char const*, char const*, ImVec2 const*, int, ImVec2 const*, ImVec2 const*) in imgui.o
      ImGui::InputTextEx(char const*, char*, int, ImVec2 const&, int, int (*)(ImGuiTextEditCallbackData*), void*) in imgui.o
  "ImDrawList::AddImage(void*, ImVec2 const&, ImVec2 const&, ImVec2 const&, ImVec2 const&, unsigned int)", referenced from:
      ImGui::Render() in imgui.o
      ImGui::Image(void*, ImVec2 const&, ImVec2 const&, ImVec2 const&, ImVec4 const&, ImVec4 const&) in imgui.o
      ImGui::ImageButton(void*, ImVec2 const&, ImVec2 const&, ImVec2 const&, int, ImVec4 const&, ImVec4 const&) in imgui.o
  "ImDrawList::AddCircle(ImVec2 const&, float, unsigned int, int)", referenced from:
      ImGui::RadioButton(char const*, bool) in imgui.o
  "ImFontAtlas::ClearTexData()", referenced from:
      _ImFontAtlas_ClearTexData in fontAtlas.o
  "ImFontAtlas::AddFontDefault(ImFontConfig const*)", referenced from:
      _ImFontAtlas_AddFontDefault in fontAtlas.o
  "ImFontAtlas::AddFontFromFileTTF(char const*, float, ImFontConfig const*, unsigned short const*)", referenced from:
      _ImFontAtlas_AddFontFromFileTTF in fontAtlas.o
  "ImFontAtlas::GetTexDataAsAlpha8(unsigned char**, int*, int*, int*)", referenced from:
      _ImFontAtlas_GetTexDataAsAlpha8 in fontAtlas.o
  "ImFontAtlas::GetTexDataAsRGBA32(unsigned char**, int*, int*, int*)", referenced from:
      _ImFontAtlas_GetTexDataAsRGBA32 in fontAtlas.o
  "ImFontAtlas::AddFontFromMemoryTTF(void*, int, float, ImFontConfig const*, unsigned short const*)", referenced from:
      _ImFontAtlas_AddFontFromMemoryTTF in fontAtlas.o
  "ImFontAtlas::AddFontFromMemoryCompressedTTF(void const*, int, float, ImFontConfig const*, unsigned short const*)", referenced from:
      _ImFontAtlas_AddFontFromMemoryCompressedTTF in fontAtlas.o
  "ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(char const*, float, ImFontConfig const*, unsigned short const*)", referenced from:
      _ImFontAtlas_AddFontFromMemoryCompressedBase85TTF in fontAtlas.o
  "ImFontAtlas::Clear()", referenced from:
      _ImFontAtlas_Clear in fontAtlas.o
      ImGui::Shutdown() in imgui.o
  "ImFontAtlas::AddFont(ImFontConfig const*)", referenced from:
      _ImFontAtlas_AddFont in fontAtlas.o
  "ImFontAtlas::ImFontAtlas()", referenced from:
      ___cxx_global_var_init1 in imgui.o
  "ImFontAtlas::~ImFontAtlas()", referenced from:
      ___cxx_global_var_init1 in imgui.o
  "ImGui::ShowUserGuide()", referenced from:
      _igShowUserGuide in cimgui.o
  "ImGui::ShowTestWindow(bool*)", referenced from:
      _igShowTestWindow in cimgui.o
  "ImGui::ShowStyleEditor(ImGuiStyle*)", referenced from:
      _igShowStyleEditor in cimgui.o
  "ImFont::CalcTextSizeA(float, float, float, char const*, char const*, char const**) const", referenced from:
      ImGui::CalcTextSize(char const*, char const*, bool, float) in imgui.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [imgui_example] Error 1

Allow disabling `__declspec(dllexport)`

When statically linking I'd like to remove all exported symbols to avoid collisions, therefor I propose either allowin to define CIMGUI_API manually or add new define CIMGUI_NO_EXPORT and don't include __declspec(dllexport) if set.

I can PR if the change is approved.

Header guard is missing

Even though there might be not many usecases to include cimgui as header in another file, I need this in my project. Unfortunately cimgui.h has no header guard, so I currently have to resort to a cimgui.include.h header with guard.

Filters are missing

Hello, I'm trying to use the ImGuiTextFilter class from your C bindings (which are great otherwise!) and couldn't find anything related to the use of text filters, especially the Draw and PassFilter methods.

imgui_impl_glfw_vulkan.h: error: unknown type name ‘ImGui_ImplGlfwVulkan_Init_Data’

I wouldn't be surprised if this file needed a little fixing up to make it a c header, but I'm a little lost on what to do.

#ifndef IMGUI_API
#define IMGUI_API
#endif
typedef struct ImGui_ImplGlfwVulkan_Init_Data ImGui_ImplGlfwVulkan_Init_Data
#include "imgui_impl_glfw_vulkan.h"

Here are my project links
data.h
imgui_impl_glfw_vulkan.h

data_bulk is just the first to include data.h.

cheako@debian:~/src/github/cheako-vulkan/012imgui$ make
cc -g -Wall -I../include    -c -o data_bulk.o data_bulk.c
In file included from data.h:14:0,
                 from data_bulk.h:1,
                 from data_bulk.c:1:
../include/imgui_impl_glfw_vulkan.h:9:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’
 struct GLFWwindow;
 ^~~~~~
../include/imgui_impl_glfw_vulkan.h:24:93: error: unknown type name ‘ImGui_ImplGlfwVulkan_Init_Data’
 Gui_ImplGlfwVulkan_Init(GLFWwindow* window, bool install_callbacks, ImGui_ImplGlfwVulkan_Init_Data *init_data);
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<builtin>: recipe for target 'data_bulk.o' failed
make: *** [data_bulk.o] Error 1

trying to use bindings in Golang

Hi, I would like to interface Imgui with Golang through this library , but I don't know where to start with cimgui.
I had already compiled the library with, make command, to a dynamic library and also to a shared library. the problem is I getting some errors when I try to build the go program and also when try to compile the test.c file.

this is what I've tried so far:

/*
#cgo CFLAGS: -I./cimgui
#cgo LDFLAGS: -L. -lcimgui
#include <cimgui.h>
*/
import "C"

func main() {

    fmt.printLn("Hello world")
}

also I've tried to include the header directly , like

/*
#include "cimgui/cimgui.h"
*/

and also I've tried to compile the test.c with gcc -c test.c
In all the cases I get the same error.

you can see the output of the error here: https://gist.github.com/michelson/8ee0996d819bb0ff8167d76d964b0fc4

thanks in advance and thanks for this library

best

"Invalid DisplaySize value" assertion failed via glew and gl3w

I tested with SDL2 (2.0.9 9bb50edccc46) on macOS 10.14 (18A391) and ported imgui_impl_opengl3.h, imgui_impl_opengl3.cpp, and main.cpp to C (checked calling to cimgui properly).

I faced with the problem of

Assertion failed: (g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value"), function NewFrame, file imgui/imgui.cpp, line 3090.
Abort trap: 6

Download the project: cimgui-sdl2.tar.gz.

To build, simply ...

  • make to build against gl3w
  • make glew to build against glew

ps.

  • notice that I have to do relative-path symlink cimgui.dylib as libcimgui.dylib, related to #78 .
  • X11 is installed at /opt/X11 and its include directory is added in Makefile as well.

Alternative preprocessors

In order to have gcc alternatives for the preprocessing I would need the output of other preproccesors

As for the gcc alternatives it seems that cl /E (MSVC) does the same as gcc -E and also clang -E

Someone with this compilers would have to generate the output of

cl /E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ../imgui/imgui.h

or any other compiler and attach it

patch: keep cimgui compatible with latest imgui head

I had to make several small changes to keep cimgui updated with the latest head, here's the diff

diff --git a/cimgui/cimgui.cpp b/cimgui/cimgui.cpp
index 61b24fa..9970b63 100644
--- a/cimgui/cimgui.cpp
+++ b/cimgui/cimgui.cpp
@@ -1047,9 +1047,9 @@ CIMGUI_API void igTreePop()
     return ImGui::TreePop();
 }

-CIMGUI_API void igSetNextTreeNodeOpened(bool opened, ImGuiSetCond cond)
+CIMGUI_API void igSetNextTreeNodeOpen(bool is_open, ImGuiSetCond cond)
 {
-    return ImGui::SetNextTreeNodeOpened(opened, cond);
+    return ImGui::SetNextTreeNodeOpen(is_open, cond);
 }

 // Widgets: Selectable / Lists
@@ -1461,19 +1461,17 @@ CIMGUI_API CONST char* igGetVersion()
     return ImGui::GetVersion();
 }

-CIMGUI_API void* igGetInternalState()
-{
-    return ImGui::GetInternalState();
+CIMGUI_API ImGuiContext* igCreateContext(void* (*malloc_fn)(size_t), void (*free_fn)(void*)) {
+    return ImGui::CreateContext(malloc_fn, free_fn);
 }
-
-CIMGUI_API size_t igGetInternalStateSize()
-{
-    return ImGui::GetInternalStateSize();
+CIMGUI_API void          igDestroyContext(ImGuiContext* ctx) {
+    ImGui::DestroyContext(ctx);
 }
-
-CIMGUI_API void igSetInternalState(void* state, bool construct)
-{
-    ImGui::SetInternalState(state, construct);
+CIMGUI_API ImGuiContext* igGetCurrentContext() {
+    return ImGui::GetCurrentContext();
+}
+CIMGUI_API void          igSetCurrentContext(ImGuiContext* ctx) {
+    ImGui::SetCurrentContext(ctx);
 }

 CIMGUI_API void ImGuiIO_AddInputCharacter(unsigned short c)
diff --git a/cimgui/cimgui.h b/cimgui/cimgui.h
index 8345e60..e6be8ae 100644
--- a/cimgui/cimgui.h
+++ b/cimgui/cimgui.h
@@ -353,9 +353,10 @@ CIMGUI_API void             igSetClipboardText(CONST char* text);

 // Internal state access - if you want to share ImGui state between modules (e.g. DLL) or allocate it yourself
 CIMGUI_API CONST char*      igGetVersion();
-CIMGUI_API void*            igGetInternalState();
-CIMGUI_API size_t           igGetInternalStateSize();
-CIMGUI_API void             igSetInternalState(void* state, bool construct);
+CIMGUI_API ImGuiContext* igCreateContext(void* (*malloc_fn)(size_t), void (*free_fn)(void*));
+CIMGUI_API void          igDestroyContext(ImGuiContext* ctx);
+CIMGUI_API ImGuiContext* igGetCurrentContext();
+CIMGUI_API void          igSetCurrentContext(ImGuiContext* ctx);

 CIMGUI_API void             ImFontAtlas_GetTexDataAsRGBA32(ImFontAtlas* atlas, unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel);
 CIMGUI_API void             ImFontAtlas_GetTexDataAsAlpha8(ImFontAtlas* atlas, unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel);
@@ -386,7 +387,7 @@ CIMGUI_API ImDrawCmd*       ImDrawList_GetCmdPtr(ImDrawList* list, int n);

 CIMGUI_API void             ImDrawList_Clear(ImDrawList* list);
 CIMGUI_API void             ImDrawList_ClearFreeMemory(ImDrawList* list);
-CIMGUI_API void             ImDrawList_PushClipRect(ImDrawList* list, CONST struct ImVec4 clip_rect); // Scissoring. The values are x1, y1, x2, y2.
+CIMGUI_API void             ImDrawList_PushClipRect(ImDrawList* list, CONST struct ImVec2 clip_rect_min, CONST struct ImVec2 clip_rect_max, bool intersect_with_current_clip_rect); // Scissoring. The values are x1, y1, x2, y2.
 CIMGUI_API void             ImDrawList_PushClipRectFullScreen(ImDrawList* list);
 CIMGUI_API void             ImDrawList_PopClipRect(ImDrawList* list);
 CIMGUI_API void             ImDrawList_PushTextureID(ImDrawList* list, CONST ImTextureID texture_id);
diff --git a/cimgui/drawList.cpp b/cimgui/drawList.cpp
index 3b9cb4f..ff3954d 100644
--- a/cimgui/drawList.cpp
+++ b/cimgui/drawList.cpp
@@ -47,9 +47,9 @@ CIMGUI_API void ImDrawList_ClearFreeMemory(ImDrawList* list)
    return list->ClearFreeMemory();
 }

-CIMGUI_API void ImDrawList_PushClipRect(ImDrawList* list, CONST struct ImVec4 clip_rect)
+CIMGUI_API void ImDrawList_PushClipRect(ImDrawList* list, CONST struct ImVec2 clip_rect_min, CONST struct ImVec2 clip_rect_max, bool intersect_with_current_clip_rect)
 {
-   return list->PushClipRect(clip_rect);
+   return list->PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect);
 }

 CIMGUI_API void ImDrawList_PushClipRectFullScreen(ImDrawList* list)

Plans to update to Dear ImGUI 1.69?

This has fallen behind a bit - Dear ImGUI is now at 1.69 and is exposing a couple of very useful methods I need to access from imgui-rs.

Will this be updated anytime soon, or should I fork it and give it a shot myself?

Creator vs Init

I have seen

CIMGUI_API struct ImGuiTextFilter *ImGuiTextFilter_Create(const char *default_filter)
{
    ImGuiTextFilter *filter = (ImGuiTextFilter *)ImGui::MemAlloc(sizeof(ImGuiTextFilter));
    IM_PLACEMENT_NEW(filter)
    ImGuiTextFilter(default_filter);
    return filter;
}

which allocates and constructs

and also

CIMGUI_API void ImFontConfig_DefaultConstructor(ImFontConfig *config)
{
    *config = ImFontConfig();
}

which takes allocated struct and inits it

but we could also have

CIMGUI_API struct ImGuiTextFilter *ImGuiTextFilter_Init(ImGuiTextFilter *filter,const char *default_filter)
{
    IM_PLACEMENT_NEW(filter) ImGuiTextFilter(default_filter);
    return filter;
}

In the auto cbinding generator I am working in:
https://github.com/sonoro1234/cimgui
I still dont know what to do, perhaps provide both? What are you, binding makers, needing?

Field accessors

How do other folks feel about exposing field accessors for structures in imgui? I've found that the most painful part of maintaining bindings is keeping structure definitions in sync. Having explicit accessor methods would help alleviate this, but it would be a very large addition. Perhaps it would only make sense to do this for a few common structures (IO, etc.).

Just to clarify, I'm referring to explicit get/set functions for fields. Something like this:

CIMGUI_API igIO_GetDisplaySize(ImGuiIO* io)
{
    return io->DisplaySize;
}

CIMGUI_API igIO_SetDisplaySize(ImGuiIO* io, ImVec2 value)
{
    io->DisplaySize = value;
}

This would be resilient to changes in the format of the ImGuiIO structure.

How have other folks been handling this in their bindings?

Generator vs Generator2

I'm experimenting with cimgui's generator to generate bindings for the ImGui docking beta branch, and it is unclear to me what the differences are between generator and generator2. The readme states to use generator, but according to this comment generator2 is more robust. Additionally, the generated files in the repo appear to have been generated with generator2.

Should the readme be updated? Is there a practical reason to keep generator around anymore if it's been superseded?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.