Files
cimgui/README.md

68 lines
5.2 KiB
Markdown
Raw Normal View History

# cimgui [![Build Status](https://travis-ci.org/sonoro1234/cimgui.svg?branch=master)](https://travis-ci.org/sonoro1234/cimgui)
2017-05-30 07:15:24 +02:00
![sample](screenshot.png)
2015-04-08 09:04:53 +02:00
This is a thin c-api wrapper programmatically generated for the excellent C++ immediate mode gui [Dear ImGui](https://github.com/ocornut/imgui).
All functions are programmatically wrapped except constructors, destructors and `ImVector`. (Unless someone find a use case for them)
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](https://github.com/Extrawurst/DerelictImgui))
2015-04-09 15:45:19 +02:00
2018-10-08 11:36:10 +02:00
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)
2015-04-21 23:56:15 +02:00
Notes:
* currently this wrapper is based on version [1.65 of Dear ImGui]
2018-10-08 12:32:09 +02:00
* overloaded function names try to be the most compatible with traditional cimgui names. So all naming is algorithmic except for those names that were in conflict with widely used cimgui names and were thus coded in a table (https://github.com/cimgui/cimgui/blob/master/generator/generator.lua#L40). Current overloaded function names can be found in (https://github.com/cimgui/cimgui/blob/master/generator/output/overloads.txt)
2015-04-09 15:45:19 +02:00
2018-08-24 18:54:46 +02:00
# compilation
2018-10-08 11:36:10 +02:00
* clone
* git clone --recursive https://github.com/cimgui/cimgui.git
* git submodule update
2018-10-08 13:44:43 +02:00
* compile
* using makefile on linux/macOS/mingw (Or use CMake to generate project)
* or as in https://github.com/sonoro1234/LuaJIT-ImGui/tree/master_auto_implementations/build
2018-08-24 18:54:46 +02:00
2018-10-08 13:44:43 +02:00
# using generator
2018-06-20 20:12:49 +02:00
2018-10-08 11:36:10 +02:00
* 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 can use also a C++ compiler for doing preprocessing: gcc (In windows MinGW-W64-builds for example), clang or cl (MSVC) or not use a compiler (experimental nocompiler option) at all. (this repo was done with gcc)
* update `imgui` folder to the version you desire.
* edit `generator/generator.bat` (or make a .sh version and please PR) to choose between gcc, clang, cl or nocompiler. Run it with gcc, clang or cl and LuaJIT on your PATH.
2018-10-08 13:44:43 +02:00
* as a result some files are generated: `cimgui.cpp` and `cimgui.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 implementations info.
# generate binding
* with your prefered languaje from lua or json files as in:
2018-10-08 13:54:58 +02:00
* https://github.com/sonoro1234/LuaJIT-ImGui/blob/master_auto_implementations/lua/build.bat (with lua code generation in https://github.com/sonoro1234/LuaJIT-ImGui/blob/master_auto_implementations/lua/class_gen.lua)
2018-10-08 13:28:50 +02:00
* https://github.com/mellinoe/ImGui.NET/tree/autogen/src/CodeGenerator
2018-10-10 14:05:08 +02:00
### 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 (may be ImGui 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)
* call_args : a string with the argument names separated by commas
* args : the same as above but with types
* ret : the return type
* argsT : an array of collections (each one with type: argument type and name: the argument name)
* 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)
2018-08-24 18:56:52 +02:00
# usage
2015-04-09 15:45:19 +02:00
2015-07-25 20:20:33 +02:00
* use whatever method is in ImGui c++ namespace in the original [imgui.h](https://github.com/ocornut/imgui/blob/master/imgui.h) by prepending `ig`
2015-04-09 15:45:19 +02:00
* methods have the same parameter list and return values (where possible)
2018-08-24 18:54:46 +02:00
* 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 another function with the name `function_name_nonUDT` is generated accepting a pointer to the UDT type as the first argument. (or second argument if it is a struct function)
* also is generated `function_name_nonUDT2` which instead of returning the UDT type returns a simple version (without functions) called `UDTType_Simple` (`ImVec2_Simple` for `ImVec2`)
2017-06-03 01:48:55 +02:00
# example bindings based on cimgui
* [DerelictImgui](https://github.com/Extrawurst/DerelictImgui)
* [ImGui.NET](https://github.com/mellinoe/ImGui.NET)
2018-08-31 09:09:17 +02:00
* [ImGuiCS](https://github.com/conatuscreative/ImGuiCS)
2017-06-03 01:48:55 +02:00
* [imgui-rs](https://github.com/Gekkio/imgui-rs)
2017-08-31 17:10:30 +02:00
* [imgui-pas](https://github.com/dpethes/imgui-pas)
2017-11-12 00:18:57 +01:00
* [odin-dear_imgui](https://github.com/ThisDrunkDane/odin-dear_imgui)
2018-06-20 15:52:33 +02:00
* [LuaJIT-imgui](https://github.com/sonoro1234/LuaJIT-ImGui)