DUI - A simple immediate mode GUI library for SDL2

It is mostly intended for debug and quick prototypes, but I want to extend its scope in the future. This library was written in C++17 to use the helpful std::string_view so we can avoid allocations.

It is an immediate mode, so you have to first setup its state like this

dui::State state{renderer};

Then send events to it:

while (SDL_PollEvent(&ev)) {

Then define your elements:

auto f = dui::frame(state);
dui::label(f, "Hello World", {100, 200});
if (dui::button(f, "Click me", {100, 220})) {
  // do some action

And finally when finish all these things, render the frame:

//SDL_RenderClear() & co.

The library is header only and it even has a single header file version too. It is hosted at https://github.com/talesm/dui, there you can also find a quick tutorial on the README and some examples under the examples directory.

1 Like

So this looks awesome, but I wanted to make an observation unrelated to
the tech:

In America, when someone gets arrested for driving a car while drunk,
that is referred to as a “DUI” (“Driving Under the Influence”) and lots
of people here would probably have a seriously negative social response
to the term.

I recognize this a local cultural thing for me, and probably not at all
in Brazil, but I just thought I’d mention it.

That being said: making decisions based on American attitudes about
anything is highly overrated. :slight_smile:

1 Like