simongeilfus / Cinder-ImGui

Dear ImGui Renderer/Wrapper for Cinder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

app quits on resize

brucelane opened this issue · comments

when I resize my Cinder app, it quits

Cannot reproduce this behaviour with the Cinder-ImGui sample.

I had same problem once, couple months back. I might take a look if It's OK now, it was some unfinished prototype.

it's just in the case you set autoRender to false. With ui::initialize(ui::Options().autoRender(true)) or ui::initialize() it's ok

Hey Bruce,
If you're unsubscribing from the Options::autoRender, I might know what's going on. Or at least I think I remember what was happening a few months ago.

Try to add a console() << "update" << getElapsedFrames() << endl in your App::update and a console() << "draw" << getElapsedFrames() << endl in your App::draw. When you resize the window you should get twice the same elapsed frame for the draw method. For some reason, the App fires twice the draw signal when you do a resize resulting in Imgui::Render being called before ImGui::NewFrame. See the conversation here.

That's the explanation behind this trick here. If you are not letting the block take care of that for you, you will need to implement a system to avoid having the ImGui::Render function called twice. If I'm correct when this happen, you should get an assert in ImGui telling you that you're calling Render before calling NewFrame?

Do you have any more details to share on why/where the app quit? Have you disabled asserts? Are you running this in Release Mode?

right, you nailed it!
here is a video showing the problem:
https://www.livecoding.tv/video/imgui-issue-18/
The draw signal is called much more than twice in my case...
You can see the assert occurring which leads to quit.

Great, so you should be able to easily fix that with something like this :

ui::NewFrame();
mIsNewFrame = true;

// ....

if( mIsNewFrame ) {
    ui::Render();
    mIsNewFrame = false;
}