-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can cimgui backends be used #157
Labels
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The way I think cimgui should be used is not by creating your own backend implementations but taking profit for those provided by imgui itself. (look at: https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md)
As a proof of concept I have just added backend_test folder. You only need to provide to cmake SDL_PATH with the path where SDL2 cmake install is found (or leave it empty -DSDL_PATH="" if it is in a folder already watched from cmake)
It will generate cimgui_sdl module and test_sdl executable that will use it from C.
If you are making a binding to another language, you only need to remake what main.c is doing.
This is a description of what is done in https://github.com/sonoro1234/LuaJIT-ImGui to use backends:
C definitions are in: https://github.com/cimgui/cimgui/blob/master/generator/output/cimgui_impl.h
(only sdl, glfw, opengl2 and opengl3 where generated but it is customizable in cimgui generation, see generator.bat (.sh))
There is no C implementation because it suffices to compile any imgui_impl_XXX.cpp for that.
(look at: https://github.com/ocornut/imgui/tree/master/backends and https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md)
You can then use directly these C definitions or wrap them in you binding languaje as done in https://github.com/sonoro1234/LuaJIT-ImGui/blob/master/lua/imgui/glfw.lua#L183 for example. You will need one platform backend and one renderer backend.
Then use them as done in: https://github.com/sonoro1234/LuaJIT-ImGui/blob/master/lua/imgui/window.lua
For using with another backends you will need to generate it by adding it in generator.sh. The compilation will need to add the relevant imgui backend cpp file and adding the define
CIMGUI_USE_backend
to CMakeList.txt. Of course you will need to write main.c yourself.The text was updated successfully, but these errors were encountered: