Skip to content

Commit 7287229

Browse files
committed
Miscellaneous warning fixes.
1 parent 46ee7b0 commit 7287229

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

imgui.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -5014,7 +5014,7 @@ static void SetupDrawListSharedData()
50145014
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_LegacyPolyline;
50155015
if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset)
50165016
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset;
5017-
g.DrawListSharedData.InitialFringeScale = g.IO.DisplayFramebufferScale.x ? 1.0f / g.IO.DisplayFramebufferScale.x : 1.0f;
5017+
g.DrawListSharedData.InitialFringeScale = 1.0f / g.IO.DisplayFramebufferScale.x;
50185018
}
50195019

50205020
void ImGui::NewFrame()
@@ -10417,6 +10417,7 @@ static void ImGui::ErrorCheckNewFrameSanityChecks()
1041710417
IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!");
1041810418
IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?");
1041910419
IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!");
10420+
IM_ASSERT(g.IO.DisplayFramebufferScale.x > 0.0f && g.IO.DisplayFramebufferScale.y > 0.0f && "Invalid DisplayFramebufferScale value!");
1042010421
IM_ASSERT(g.IO.Fonts->IsBuilt() && "Font Atlas not built! Make sure you called ImGui_ImplXXXX_NewFrame() function for renderer backend, which should call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8()");
1042110422
IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!");
1042210423
IM_ASSERT(g.Style.CircleTessellationMaxError > 0.0f && "Invalid style setting!");

imgui_draw.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,6 @@ void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, c
723723
// - Those macros expects l-values and need to be used as their own statement.
724724
// - Those macros are intentionally not surrounded by the 'do {} while (0)' idiom because even that translates to runtime with debug compilers.
725725
#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = ImRsqrt(d2); VX *= inv_len; VY *= inv_len; } } (void)0
726-
#define IM_NORMALIZE2F_OVER_ZERO_PRECISE(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = ImRsqrtPrecise(d2); VX *= inv_len; VY *= inv_len; } } (void)0
727726
#define IM_FIXNORMAL2F_MAX_INVLEN2 100.0f // 500.0f (see #4053, #3366)
728727
#define IM_FIXNORMAL2F(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 > 0.000001f) { float inv_len2 = 1.0f / d2; if (inv_len2 > IM_FIXNORMAL2F_MAX_INVLEN2) inv_len2 = IM_FIXNORMAL2F_MAX_INVLEN2; VX *= inv_len2; VY *= inv_len2; } } (void)0
729728

@@ -877,17 +876,20 @@ IM_STATIC_ASSERT(2 * sizeof(ImDrawIdx) == sizeof(ImU64)); // assumption: ImU64 m
877876

878877
#define IM_POLYLINE_MITER_ANGLE_LIMIT -0.9999619f // cos(179.5)
879878

879+
#if defined(__clang__)
880+
// Make macros call site look nicer, without needing us to add do { } while (0) statements
881+
#pragma clang diagnostic ignored "-Wextra-semi-stmt" // warning: empty expression statement has no effect; remove unnecessary ';' to silence this
882+
//#pragma clang diagnostic ignored "-Wcast-align" //// warning: empty expression statement has no effect; remove unnecessary ';' to silence this
883+
#endif
884+
880885
void ImDrawList::_PolylineEmitArcs(const ImDrawListPolyline& polyline, const int arc_count, const float core_radius, const float fringe_radius)
881886
{
882887
if (arc_count == 0) IM_UNLIKELY
883888
return;
884889

885890
const float max_radius = ImMax(core_radius, fringe_radius);
886891
const int max_arc_segment_count = ImMax((_CalcCircleAutoSegmentCount(max_radius) + 1) / 2, 2);
887-
const int arc_arm_point_count = (core_radius > 0.0f ? 1 : 0) + (fringe_radius > 0.0f ? 1 : 0);
888-
889-
if (arc_arm_point_count < 0 || arc_arm_point_count > 2) IM_UNLIKELY
890-
return;
892+
const int arc_arm_point_count = (core_radius > 0.0f ? 1 : 0) + (fringe_radius > 0.0f ? 1 : 0); // Output 0..2
891893

892894
const int max_arc_vtx_count = arc_arm_point_count * (max_arc_segment_count + 2) + 1; // 1 for the center vertex
893895
const int max_arc_idx_count = max_arc_segment_count * (1 + (arc_arm_point_count - 1) * 2) * 3;
@@ -3583,7 +3585,7 @@ void ImDrawList::_RoundedRect(const ImVec2& a, const ImVec2& b, ImU32 col, floa
35833585
col = (col & ~IM_COL32_A_MASK) | (alpha << IM_COL32_A_SHIFT);
35843586
}
35853587

3586-
if (screen_thickness <= 1.0f) IM_LIKELY // thin
3588+
if (screen_thickness <= 1.0f) IM_UNLIKELY // thin
35873589
{
35883590
path_offsets[0].x = thickness; path_offsets[0].y = thickness;
35893591
path_offsets[1].x = 0.0f; path_offsets[1].y = 0.0f;

0 commit comments

Comments
 (0)