Skip to content

ImGui IdxOffset not honored correctly during frame drawing #86

@jvannugteren

Description

@jvannugteren

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status
    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions