Developer knowledge network · moderated exchange

Zajednica UnreliableCode

Zajednica za istraživanje, obrnuti inženjering i programiranje programera

Knowledge indexŽivjeti
4Categories
919Threads
2.8KPostovi
Release

Dynamic Weapon Crosshair HUD with Real-Time Bullet Spread Circle in ImGui [v2.4 Technical Discussion]

imgui_artisan
UI Designer
MEMBER
Rep: 202
Datum pridruživanja: Apr 2019
Postovi: 54
Hvala: 28
3 prije tjedana · Aug 2, 2026 5:59 AM
#1

A responsive dynamic crosshair widget for GTA V:

CPP
void DrawDynamicCrosshair(Vector2 screenCenter, float spreadRadius, ImU32 color) {
    ImDrawList* dl = ImGui::GetBackgroundDrawList();
    float gap = max(4.0f, spreadRadius * 20.0f); // Expands as spread increases
    float len = 8.0f;
    
    // Top, Bottom, Left, Right crosshair lines
    dl->AddLine(ImVec2(screenCenter.x, screenCenter.y - gap), ImVec2(screenCenter.x, screenCenter.y - gap - len), color, 2.0f);
    dl->AddLine(ImVec2(screenCenter.x, screenCenter.y + gap), ImVec2(screenCenter.x, screenCenter.y + gap + len), color, 2.0f);
    dl->AddLine(ImVec2(screenCenter.x - gap, screenCenter.y), ImVec2(screenCenter.x - gap - len, screenCenter.y), color, 2.0f);
    dl->AddLine(ImVec2(screenCenter.x + gap, screenCenter.y), ImVec2(screenCenter.x + gap + len, screenCenter.y), color, 2.0f);
}
fivem_native_coder
Lua Scripter
MEMBER
Rep: 64
Datum pridruživanja: Jun 2019
Postovi: 20
Hvala: 48
3 prije tjedana · Aug 2, 2026 11:29 AM
#2

The crosshair dynamically expands when running or firing and snaps tight when standing still. Beautiful HUD design.

matrix_math_guy
Math Specialist
MEMBER
Rep: 105
Datum pridruživanja: Aug 2018
Postovi: 52
Hvala: 41
3 prije tjedana · Aug 2, 2026 5:09 PM
#3

Clean ImGui rendering.