Skip to content

Commit

Permalink
minor change: moved int cast to avoid potential problems with 32bit i…
Browse files Browse the repository at this point in the history
…ndices
  • Loading branch information
sergeyn committed May 21, 2020
1 parent 3d2b3b0 commit dc84261
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions implot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2210,7 +2210,7 @@ template<int flags, typename Getter> void RenderLineStrip(Getter& getter, ImDraw
const ImVec2 uv = DrawList._Data->TexUvWhitePixel;
while (segments)
{
int cnt = std::min(segments, (int/*todo - remove this cast*/)(((size_t(1) << sizeof(ImDrawIdx) * 8)-1 - DrawList._VtxCurrentIdx) / 4)); // find how many can be reserved up to end of current draw command's limit
int cnt = (int/*todo - remove this cast*/)std::min(size_t(segments), (((size_t(1) << sizeof(ImDrawIdx) * 8)-1 - DrawList._VtxCurrentIdx) / 4)); // find how many can be reserved up to end of current draw command's limit
if (cnt >= std::min(64,segments))
{
if constexpr ((flags & RenderLineStrip_Cull) != 0)
Expand All @@ -2234,7 +2234,7 @@ template<int flags, typename Getter> void RenderLineStrip(Getter& getter, ImDraw
segments_culled = 0;
}

cnt = std::min(segments, (int/*todo - remove this cast*/)(((size_t(1) << sizeof(ImDrawIdx) * 8) - 1 - 0/*DrawList._VtxCurrentIdx*/) / 4));
cnt = (int/*todo - remove this cast*/) std::min(size_t(segments), (((size_t(1) << sizeof(ImDrawIdx) * 8) - 1 - 0/*DrawList._VtxCurrentIdx*/) / 4));
DrawList.PrimReserve(cnt * 6, cnt * 4); // reserve new draw command
}

Expand Down

0 comments on commit dc84261

Please sign in to comment.