Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krasjet/imgui_juce
JUCE backend for Dear ImGui
https://github.com/krasjet/imgui_juce
audio cpp gui imgui juce juce-framework opengl vst vst3
Last synced: 2 months ago
JSON representation
JUCE backend for Dear ImGui
- Host: GitHub
- URL: https://github.com/krasjet/imgui_juce
- Owner: Krasjet
- License: lgpl-3.0
- Created: 2022-10-16T05:13:36.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-06T05:45:41.000Z (7 months ago)
- Last Synced: 2024-10-13T23:49:02.139Z (3 months ago)
- Topics: audio, cpp, gui, imgui, juce, juce-framework, opengl, vst, vst3
- Language: C++
- Homepage:
- Size: 353 KB
- Stars: 36
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE
Awesome Lists containing this project
README
imgui_juce
==========JUCE [1] backend for Dear ImGui [2].
I don't recommend using JUCE for prototyping DSP code, but
if you have no better options, using ImGui with this library
should make your life a lot easier.Pros:
+ No more listener/attachment/callback bullshit (you won't
believe how many layers of callbacks are used just to
set a single parameter using APVTS's SliderAttachment).You can write declarative code for GUI now:
ImGui::Text("Hello, world %d", 123);
if (ImGui::Button("Save"))
DoStuff();+ No more GUI layout positioning bullshit. Spend your time
on DSP code.+ It's much easier now to integrate custom non-float
parameters into your plugin.+ There are a ton of useful extensions for ImGui you can
use for easier debugging. See imnodes [3], implot [4],
and the list on ImGui wiki [5].+ You can mix JUCE GUI components and ImGui. ImGui only
needs a Component for mouse/keyboard input and a
OpenGLContext for rendering. You can, for example, only
enable the ImGui component for debugging and disable it
in the final release.Cons:
- GUI is recomputed each frame at 60 FPS, probably less
efficient than JUCE, but at least it's using OpenGL.- JUCE's keypress callbacks are extremely inefficient for
ImGui, though you can disable it by settingsetWantsKeyboardFocus(false);
- Component and layout can be less customizable than JUCE.
You probably only want to use it for prototyping.- Slider skew not supported by default. You need to write
your own component for that (contributions welcome).
ImGui do have logarithmic slider built-in though.- You need a patched version of ImGui for use in audio
plugins (see Note below).Usage
-----The backend exposes three functions
#include
void ImGui_ImplJuce_Init(juce::Component&, juce::OpenGLContext&);
void ImGui_ImplJuce_Shutdown();
void ImGui_ImplJuce_NewFrame();You need to create a juce::OpenGLRenderer and call the three
functions invoid newOpenGLContextCreated();
void openGLContextClosing();
void renderOpenGL();respectively. See
./examples/mwe/src/ImGuiComponent.h
for a complete minimal working example.
If you need an audio plugin example, see
./examples/sine/
CMake Usage
-----------If you are using CMake, call `add_subdirectory` on the
current directory after JUCE directory is added. Then link
your application target to `imgui_imple_juce`. For example,target_link_libraries(app
# other stuff libs
PRIVATE
imgui_impl_juce)See
./examples/mwe/CMakeLists.txt
for a complete example.
Note
----By default ImGui only support a single instance running
because it uses a global stateImGuiContext* GImGui = NULL;
This is probably fine if you are writing a GUI application,
but if you are writing an audio plugin, the plugin will
crash if you add multiple instances of the plugin in DAW and
open two GUIs at the same time.You need to patch ImGui and make the global state thread local
thread_local ImGuiContext* GImGui = NULL;
in order to support multiple instances of ImGui running at
the same time on different threads. See./examples/sine/patches/imgui/multi_instance.patch
for details.
You need a similar patch if you want to use imnodes or
ImPlot in your plugin. For a ImPlot example, see./examples/scope/patches/implot/multi_instance.patch
License
-------The imgui_juce library is licensed under the GNU Lesser
General Public License v3.0 (LGPLv3).Examples are placed under public domain.
Donate
------If this library saves valuable development time for you,
consider donate to support this project:https://ko-fi.com/krjst
--------------------------
[1]: https://github.com/juce-framework/JUCE
[2]: https://github.com/ocornut/imgui
[3]: https://github.com/Nelarius/imnodes
[4]: https://github.com/epezent/implot
[5]: https://github.com/ocornut/imgui/wiki/Useful-Extensions