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

ImGui IdxOffset not honored correctly during frame drawing #86

Closed
jvannugteren opened this issue Jan 11, 2022 · 4 comments
Closed

ImGui IdxOffset not honored correctly during frame drawing #86

jvannugteren opened this issue Jan 11, 2022 · 4 comments

Comments

@jvannugteren
Copy link

jvannugteren commented Jan 11, 2022

Using the magnum-integration I get the following graphical glitch with ImGui:
https://github.com/ocornut/imgui/releases/tag/v1.86 (see first section)

I have created an issue there. However, I was pointed out by Ocornut, creator of imgui, it is an issue with the backend (i.e. Magnum) not honoring the ImDrawCmd::IdxOffset correctly.

See the following ImGui issues (all the same):
ocornut/imgui#4887 (this one is mine)
ocornut/imgui#4863
ocornut/imgui#4845

I think the (easy) fix is to change src/Magnum/ImGuiIntegration/Context.cpp line 328 to:

_mesh.setIndexBuffer(_indexBuffer, pcmd->IdxOffset*sizeof(ImDrawIdx),
                sizeof(ImDrawIdx) == 2
                ? GL::MeshIndexType::UnsignedShort
                : GL::MeshIndexType::UnsignedInt);

Lines 310 and 333 then become obsolete. This way the IdxOffset of ImGui is respected and not re-calculated by magnum. With this change the glitch goes away at least in my code. Please check what I did as I'm not fully familiar with your code.

Thanks for looking at this.

@pezcode
Copy link
Contributor

pezcode commented Jan 11, 2022

I have a patch for this, just stashed it because there was some other work I originally wanted to do on ImGuiIntegration. I can send a PR tomorrow ☺️

@jvannugteren
Copy link
Author

Thanks. Did you happen to also fix the key events? Then I won't need to make another issue.

@pezcode
Copy link
Contributor

pezcode commented Jan 11, 2022

Thanks. Did you happen to also fix the key events? Then I won't need to make another issue.

Hm no, not aware of key event issues. Feel free to file an issue.

@mosra
Copy link
Owner

mosra commented Jan 31, 2022

Thanks! The code here originates way before 1.71 was a thing and since I'm not using ImGui myself, I'm not really reading the changelogs and so I missed this, sorry -- glad you've discovered the issue instead.

#88 got merged as 3e7b175, so this can be closed.

@mosra mosra closed this as completed Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

3 participants