A bridge for Lua GFX based scripts to render them with ReaImGui.

It started as a small Lua experiment by Cfillion: what if we redirect all Lua GFX function call from an existing script to ReaImGui?

The native ReaScript GUI engine, GFX is very nice, and you have seen some really advanced stuff made with it right on this website, but it has few quirks: it hasn’t anti-aliaising for every shapes, and it’s doesn’t work very well with moving shapes as it hasn’t very stable refresh rate.

Thing is that ReaImGui, Cfillion’s port to DearImGui engine to REAPER, has such things, as it renders using OpenGL, or Direct3D on Windows.

That is how he started to write some kind of bridge in Lua, to replace GFX functions by ReaImGui ones, running in a ReaImgui context rather than GFX. A simple lua file called gfx2imgui.lua. And… it works!

GFX on the Left, ReaImGui on the right. You can see the obvious benefit of anti-aliasing.

During a discussion, he reveals his experiments. So I tried with one of my most advanced GUI script and wow, the success was immediate! The refreshing rate was way better, the drawing was more neat. I have been waiting for this since years.

GFX rendering with moving shapes on my ReaTab Hero script (I will showcase in a next article).
ReaImGui rendering with moving shapes. See how smoother the scrolling is.

We fine-tuned both the script and the bridge to make it works nicely and he finally released gfx2reaimgui.lua in the ReaTeam Extension repository, so that it is accessible to anyone using Reapack.

It is a bit crazy that it works considering how different these rendering engine are. There are some core difference, so the initial script may need some optimization to be really compatible, but you can deliver both GFX and ReaImGui version in parallel. Some unresolved issues so far are due to DearImGui limitations, like unicode character rendering. Cfillion has since continuously updates the script when other fixable edge cases have been found and according to ReaImGui updates.

If you want to experiment as well, I made a template to GFX2ReaImGui any GFX script. It is a simple script which check a script of your choice, and check the presence of the gfx2imgui.lua, and run both if the tests passed.

From my knowledge, only one other script than ReaTab Hero so far uses this bridge as default: MKSlicer 3, already showcased on ReaLinks. It can also be niced to add some ReaImGui elements (buttons, table) to a script which has initially be designed with GFX.

You can see details and ask for support on the forum thread below. And if you are curious, you can take a look at gfx2imgui.lua source code here.

Happy -anti-aliased- coding! 🖥

New on [url=][/url]:


Notify of
Inline Feedbacks
View all comments