Home / Forums / How to draw Snaplines and Skeleton ESP cleanly using ImDrawList

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Source

How to draw Snaplines and Skeleton ESP cleanly using ImDrawList

GlowShader
Shader & Overlay Artist
MEMBER
Rep: 185
Join Date: Oct 2023
Posts: 36
Thanks: 46
2y ago · Apr 8, 2024 4:15 PM
#1
Sharing my helper functions for drawing bottom-center snaplines and connected skeletal bones in Dear ImGui:

CPP
// Draw Snapline from bottom screen center to enemy origin/feet
void DrawSnapline(const ImVec2& targetScreenPos, ImU32 color, float thickness = 1.0f) {
    ImVec2 screenCenterBottom = ImVec2(ImGui::GetIO().DisplaySize.x * 0.5f, ImGui::GetIO().DisplaySize.y);
    ImGui::GetBackgroundDrawList()->AddLine(screenCenterBottom, targetScreenPos, color, thickness);
}

// Draw Bone Segment
void DrawBoneSegment(const Vector3& from, const Vector3& to, ImU32 color) {
    Vector2 screenFrom, screenTo;
    if (WorldToScreen(from, screenFrom) && WorldToScreen(to, screenTo)) {
        ImGui::GetBackgroundDrawList()->AddLine(
            ImVec2(screenFrom.x, screenFrom.y),
            ImVec2(screenTo.x, screenTo.y),
            color, 1.5f
        );
    }
}


Tips for smooth rendering:
- Set
CPP
ImDrawListFlags_AntiAliasedLines
for smooth anti-aliasing.
- Draw bounding boxes and text names using
CPP
ImGui::GetBackgroundDrawList()
so they appear cleanly behind your ImGui menu windows.
GlowShader | Shaders, Stencils & DirectX DrawLists
The following users thanked GlowShader for this post:
RenderMaster
ImGui UI Designer
VIP
Rep: 310
Join Date: Sep 2023
Posts: 32
Thanks: 82
2y ago · Apr 8, 2024 6:20 PM
#2
A small optimization tip: you can add an outline/drop-shadow effect to snaplines and skeleton lines by drawing a 3.0f thickness black line underneath first, then the 1.5f colored line on top! It makes lines pop out against light backgrounds.
RenderMaster | Clean UI Design & Dear ImGui widgets
ZeroMemory
Member
MEMBER
Rep: 75
Join Date: Oct 2024
Posts: 32
Thanks: 18
2y ago · Apr 9, 2024 11:05 AM
#3
The drop shadow trick looks amazing in-game! Thank you @GlowShader and @RenderMaster.
ZeroMemory · Always experimenting