Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make subsequent window creation possible #1827

Closed
wants to merge 2 commits into from
Closed

Make subsequent window creation possible #1827

wants to merge 2 commits into from

Conversation

ice1000
Copy link
Contributor

@ice1000 ice1000 commented May 20, 2018

Context

I'm the author of the Java binding of dear-imgui, and I want to do GUI tests (say, running some GUI windows on a non-headless machine and automatically stop after a few seconds).
But when I was running the second window, I saw:

java: /home/ice1000/git-repos/jimgui/core/jni/imgui/imgui.cpp:3484:void ImGui::NewFrame():
假设 ‘g.IO.DeltaTime >= 0.0f && "Need a positive DeltaTime (zero is tolerated but will cause some timing issues)"’ 失败。

(假设 == assume, 失败 == failed)

After some debugging I found that when I initialize glfw the second time, glfwGetTime is reset to 0 (or, very close to 0) but g_Time (a static global variable) isn't. And DeltaTime is set to current_time - g_Time which is negative under this circumstance.

io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f)

Modifications

  • Added ifndef/define/endif to gl2/gl3 example header files
  • Re-initialize g_Time in ImGui_ImplGlfwGLX_Init

ocornut added a commit that referenced this pull request May 21, 2018
…by reseting the time storage properly). Changelog. Added to Vulkan example. (#1827)
@ocornut
Copy link
Owner

ocornut commented May 21, 2018

@ice1000 I have merged the change of reseting time (and applied it to the GLFW+Vulkan example). Thanks!

I took the liberty to squash the commits and remove the addition of #ifndef etc. blocks. However small, if you submit two unrelated changes please try to explain the rationale for each changes put them into separate commits so they can be cherry picked separately. Generally we try to use #pragma once for this purpose, though I wonder which problem you were trying to solve (consider that the header file is very small and probably only used in one or two place of a codebase.)

Thank again!

@ocornut ocornut closed this May 21, 2018
@ice1000
Copy link
Contributor Author

ice1000 commented May 21, 2018

Get it.

Please continue working on this awesome project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants