-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Memory stomping with ImGuiKey_XXX elements after ImGuiKey_COUNT_ #2063
Comments
Hello, I am not sure what is happening but here's a few hints.
|
Hi Omar, Thanks for the tips.
I'm not sure if it's necessarily relevant to this, but I have linked ImGui dynamically to my application (stored in a DLL). In the older 1.49-1.50 version, I had to get a little creative to get the multi-context switching to work right, but the new version seems like it should be more turn-key in that regard. |
Mind that imgui_impl_opengl3.cpp currently won't work with that setup (it stores a single texture) but it's not too hard to mod it.
The API are cleaner and there's no default global context instance any more (only a pointer which needs to be set explicitely) which makes it much less error prone (especially as DLL hot-loading would affect the global) but aside from that the logic should be the same. |
So I've narrowed it down to |
Found it! So the root of the problem is that I have defined extra ImGuiKey_ enums in my user header, and in the previous version, the ImGuiIO::KeyMap array was something like 512 elements wide. Now it is narrowed to the default key count: However, I am mapping extra keys than are defined by default: So at a certain point, the assignment operations were overwriting values outside the array. In this case, it was the Fonts pointer. This explains why it was the same value each time. Do you have a recommendation for how to tenably modify the KeyMap size to accommodate user-specified keys? Or should I just set it back to some arbitrarily large number like 512? |
KeyMap[] was always
The initial intent behind this mechanism was to encourage people using their own native key enumeration (so your code instead of using an hypothetical In reality there are pros and cons of both ways. TL;DR; I agree this enum should be populated at some point. Also see: #2005, #1924. |
You're right, I must have modified it a year ago and forgot. Changing the array size to a sufficient width fixed the problem. Yes I'm creating a sort of internal SDK, so using the ImGuiKey_ method just helps with overall cohesiveness. But it's an easy fix. Thanks again for the help. Issue closed. |
Version/Branch of Dear ImGui:
1.63
Back-end file/Renderer/OS:
Back-ends: imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp
OS: Windows 10
Compiler: MSVC 2015
My Issue/Question:
After upgrading from 1.50 to 1.63, and correspondingly upgrading the GLFW/OpenGL backends and their integration into my application, I am having trouble at
ImGui_ImplOpenGL3_CreateFontsTexture()
. At the following line (line 309 of imgui_impl_opengl3.cpp below),io.Fonts
is undefined, and thus theGetTexDataAsRGBA32()
function fails:I'm using the default backends, and have even tried writing my own, but I keep getting stuck at this problem.
Because I am using multiple contexts, I am using
CreateContext()
andDestroyContext()
appropriately, and am switching context appropriately usingSetCurrentContex()
before each implementation call. I have tried to manually create a new FontAtlas* before callingImGui_ImplOpenGL3_CreateFontsTexture()
, which allows the application to continue execution, but it yields a blank render with no ImGui content, so I'm assuming it's some sort of context issue.Does anyone have any insight?
Standalone, minimal, complete and verifiable example:
See image above. Default example.
The text was updated successfully, but these errors were encountered: