Skip to content

Commit

Permalink
ImGuiIntegration: use ImDrawCmd::IdxOffset
Browse files Browse the repository at this point in the history
Manually calculating the index buffer offset isn't correct (despite the
comment for IdxOffset indicating otherwise). This surfaced with changes
in v1.86 under certain circumstances, e.g. stacked modals. See
ocornut/imgui#4845.
  • Loading branch information
pezcode authored and mosra committed Jan 31, 2022
1 parent 9d9ac4f commit 3e7b175
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/Magnum/ImGuiIntegration/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ void Context::drawFrame() {

for(std::int_fast32_t n = 0; n < drawData->CmdListsCount; ++n) {
const ImDrawList* cmdList = drawData->CmdLists[n];
ImDrawIdx indexBufferOffset = 0;

_vertexBuffer.setData(
{cmdList->VtxBuffer.Data, std::size_t(cmdList->VtxBuffer.Size)},
Expand All @@ -325,13 +324,11 @@ void Context::drawFrame() {
.scaled(_supersamplingRatio)});

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

indexBufferOffset += pcmd->ElemCount;

_shader
.bindTexture(*static_cast<GL::Texture2D*>(pcmd->TextureId))
.draw(_mesh);
Expand Down

0 comments on commit 3e7b175

Please sign in to comment.