Developer knowledge network · moderated exchange

Супольнасць UnreliableCode

Супольнасць распрацоўшчыкаў даследаванняў, зваротнага праектавання і кадавання

Knowledge indexжыць
4Categories
919Threads
2.8KПаведамленні
Release

Custom Crosshair & Dynamic FOV circle rendering in DirectX 11

imgui_artisan
UI Designer
MEMBER
прадстаўнік: 202
Дата далучэння: Apr 2019
Паведамленні: 54
Дзякуй: 28
1 месяцаў таму · Jul 25, 2026 4:39 AM
#1

Draw an interactive FOV circle and customizable crosshair with Dear ImGui:

CPP
void DrawHUDOverlay(float fovRadius, ColorRGB crossColor) {
    ImVec2 screenCenter = ImVec2(ImGui::GetIO().DisplaySize.x / 2.0f, ImGui::GetIO().DisplaySize.y / 2.0f);
    ImDrawList* drawList = ImGui::GetBackgroundDrawList();
    
    // Draw FOV boundary circle
    drawList->AddCircle(screenCenter, fovRadius, IM_COL32(255, 255, 255, 120), 64, 1.5f);
    
    // Draw Dot Crosshair with shadow outline
    drawList->AddCircleFilled(screenCenter, 3.5f, IM_COL32(0, 0, 0, 200));
    drawList->AddCircleFilled(screenCenter, 2.0f, IM_COL32(crossColor.r, crossColor.g, crossColor.b, 255));
}
fivem_native_guru
CitizenFX Dev
MEMBER
прадстаўнік: 182
Дата далучэння: May 2021
Паведамленні: 8
Дзякуй: 69
1 месяцаў таму · Jul 25, 2026 6:47 AM
#2

The shadow outline behind the crosshair dot makes it visible against both bright sky and dark night scenes.

matrix_math_guy
Math Specialist
MEMBER
прадстаўнік: 105
Дата далучэння: Aug 2018
Паведамленні: 52
Дзякуй: 41
4 тыдняў таму · Jul 26, 2026 1:02 AM
#3

Using GetBackgroundDrawList() avoids window clipping. Very clean.