Developer knowledge network · moderated exchange

Społeczność UnreliableCode

Badania programistów, inżynieria wsteczna i społeczność programistów

Knowledge indexNa żywo
4Categories
919Threads
2.8KPosty
Release

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

imgui_artisan
UI Designer
MEMBER
Rozpustnik: 202
Data dołączenia: Apr 2019
Posty: 54
Dzięki: 28
3 tygodnie temu · 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
Rozpustnik: 64
Data dołączenia: Jun 2019
Posty: 20
Dzięki: 48
3 tygodnie temu · 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
Rozpustnik: 105
Data dołączenia: Aug 2018
Posty: 52
Dzięki: 41
3 tygodnie temu · Aug 2, 2026 5:09 PM
#3

Clean ImGui rendering.