Skip to content
New issue

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

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

Already on GitHub? # to your account

IMGUI_DISABLE_OBSOLETE_FUNCTIONS affects layout of ImGuiIO #1695

Closed
zx64 opened this issue Mar 24, 2018 · 5 comments
Closed

IMGUI_DISABLE_OBSOLETE_FUNCTIONS affects layout of ImGuiIO #1695

zx64 opened this issue Mar 24, 2018 · 5 comments

Comments

@zx64
Copy link

zx64 commented Mar 24, 2018

This issue is more a heads up for anyone else that might run into this because of project build settings etc.

Example symptom: reading io.MouseWheel etc. in your code stays zero despite it scrolling windows, showing up as non-zero in the demo window etc.

The cause is inconsistently defining IMGUI_DISABLE_OBSOLETE_FUNCTIONS throughout your project, which means some (but not all) member accesses after the RenderDrawListsFn function pointer will be the incorrect offset.

This can be verified by looking at the disassembly of an affected function: devenv

Entirely my fault of course, hopefully nobody else runs into this! (Equally, hopefully there's enough keywords for someone to find this if it does happen to them)

ocornut added a commit that referenced this issue Mar 25, 2018
@franciscod
Copy link
Contributor

Just got bitten by this. Thanks for the heads-up!

@ocornut
Copy link
Owner

ocornut commented Apr 22, 2018

@zx64 @franciscod May I ask you both how/where did you try to put those define?
The documentation states in multiple place that they need to be in imconfig.h for that reason. I now have added some extra commentary last month as you can see in the commit above.

I'm just trying to understand why/how you got it wrong so I can find way to reduce the likehood it happens to other people. Perhaps need to add a mechanism that requires passing sizeof(ImGuiIO) etc. to the cpp file so the value from different compilation unit can be compared.

@franciscod
Copy link
Contributor

franciscod commented Apr 22, 2018 via email

ocornut added a commit that referenced this issue Apr 25, 2018
…tructure sizes in order to catch issues with mismatching compilation unit settings. (#1695, #1769)
ocornut added a commit that referenced this issue Apr 25, 2018
@ocornut
Copy link
Owner

ocornut commented Apr 25, 2018

I have added a macrio IMGUI_CHECKVERSION() which checks the size of data structures which are mostly likely to be affected by mismatching compilation settings or mismatching configuration option.

All the examples are now calling IMGUI_CHECKVERSION() in their main.cpp code, which hopefully means that new users will adopt it naturally in their own codebase. Also added a comment about it in imconfig.h so hopefully more people will see it.

Closing this.

@ocornut ocornut closed this as completed Apr 25, 2018
@franciscod
Copy link
Contributor

Nice idea! Thanks!

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

No branches or pull requests

3 participants