How to get ImGui working properly

Hey everyone!

I am trying to use Cinders’ ImGui functionality and had a couple of questions. I have been following this post and followed the examples that I ended up finding. But I have run into some issues.

  1. All the examples seem to use a version of ImGui::Initialize() that does not require a parameter for me. I need to create an Options object and then pass that in. Is that just a difference in the API, and they are using older versions? Or am I doing something wrong?
  2. When I do run the code below my ImGui window is tiny. When I resize my window it stays the same size as well. Although in the API it looks like the window should resize if the Cinder App window resizes, so how do I control the size of the ImGui window itself? Did i miss something in the API?

Here is the code I am using:
WindowRef window = app::getWindow();
ImGui::Options options = ImGui::Options();
options.window(window, 1);
ImGui::Initialize(options);
ImGui::Begin(“Hello World”);
ImGui::Text(“Solar System”);
ImGui::End();

And a screenshot of what it looks like:

When you resize an ImGui window, the app should automatically remember its size and position for the next time you restart it. By default, Cinder attempts to save this configuration to a file called imgui.ini within the assets/ folder. This will fail if that folder doesn’t exist in your project’s directory.

To set a default size and position for your ImGui window, you can use something like this:

ImGuiCond kFlags = ImGuiCond_FirstUseEver;
const vec2 kWinPos = { 10, 10 };
const vec2 kWinSize = { 300, 500 };
ui::SetWindowPos( “Parameters”, kWinPos, kFlags );
ui::SetWindowSize( “Parameters”, kWinSize, kFlags );
ui::ScopedWindow window( “Parameters” );
1 Like

This worked for me, thank you so much!

1 Like