Skip to content

Instantly share code, notes, and snippets.

@luukvbaal
Created August 3, 2026 22:21
Show Gist options
  • Select an option

  • Save luukvbaal/f3989e21aa78d16f3265ebc08662d232 to your computer and use it in GitHub Desktop.

Select an option

Save luukvbaal/f3989e21aa78d16f3265ebc08662d232 to your computer and use it in GitHub Desktop.
sdr velo
diff --git a/bin/data/profiles/default.ini b/bin/data/profiles/default.ini
index d8ae7f5..2a0ac1a 100644
--- a/bin/data/profiles/default.ini
+++ b/bin/data/profiles/default.ini
@@ -122,6 +122,14 @@ velo_font_size=48
# This is the color of the text.
velo_color=200 200 200 255
+# The RGBA color components between 0 and 255.
+# This is the color of the text used when velocity is increasing.
+velo_color_inc=0 255 255 255
+
+# The RGBA color components between 0 and 255.
+# This is the color of the text used when velocity is decreasing.
+velo_color_dec=255 0 255 255
+
# The RGBA color components between 0 and 255.
# This is the color of the text border.
velo_border_color=0 0 0 255
@@ -157,6 +165,9 @@ velo_anchor=center
# Length of which velocity to show. Possible values are: xy, xyz, z.
velo_length=xy
+# How often to update the velocity. Every 1-60 frames.
+velo_frames=10
+
#################################################################
# Input overlay
#################################################################
diff --git a/src/svr_game/proc_profile.cpp b/src/svr_game/proc_profile.cpp
index aeb7588..712646a 100644
--- a/src/svr_game/proc_profile.cpp
+++ b/src/svr_game/proc_profile.cpp
@@ -189,6 +189,9 @@ bool ProcState::movie_load_profile(const char* name)
ret &= OPT_STR(&ini_root, "velo_font", movie_profile.velo_font);
ret &= OPT_S32(&ini_root, "velo_font_size", 16, 192, &movie_profile.velo_font_size);
ret &= OPT_COLOR(&ini_root, "velo_color", &movie_profile.velo_font_color);
+ ret &= OPT_COLOR(ini_root, "velo_color_inc", &movie_profile.velo_font_color_inc);
+ ret &= OPT_COLOR(ini_root, "velo_color_dec", &movie_profile.velo_font_color_dec);
+ ret &= OPT_S32(ini_root, "velo_frames", 1, 60, &movie_profile.velo_frames);
ret &= OPT_COLOR(&ini_root, "velo_border_color", &movie_profile.velo_font_border_color);
ret &= OPT_S32(&ini_root, "velo_border_size", 0, 192, &movie_profile.velo_font_border_size);
ret &= OPT_S32(&ini_root, "velo_shadow_offset", 0, 192, &movie_profile.velo_shadow_offset);
diff --git a/src/svr_game/proc_state.h b/src/svr_game/proc_state.h
index e80f7cb..792328d 100644
--- a/src/svr_game/proc_state.h
+++ b/src/svr_game/proc_state.h
@@ -51,9 +51,12 @@ struct MovieProfile
// Velo options:
s32 velo_enabled;
+ s32 velo_frames;
char velo_font[128];
s32 velo_font_size;
SvrVec4I velo_font_color;
+ SvrVec4I velo_font_color_inc;
+ SvrVec4I velo_font_color_dec;
SvrVec4I velo_font_border_color;
s32 velo_font_border_size;
s32 velo_shadow_offset;
diff --git a/src/svr_game/proc_velo.cpp b/src/svr_game/proc_velo.cpp
index d4f3bcb..2b66fa0 100644
--- a/src/svr_game/proc_velo.cpp
+++ b/src/svr_game/proc_velo.cpp
@@ -133,11 +133,22 @@ void ProcState::velo_draw()
}
}
- float length = velo_get_length(front);
- s32 speed = (s32)(sqrtf(length) + 0.5f);
+ static SvrVec4I color;
+ static s32 draw_speed = 0;
+ static s32 skip_update = 1;
+ // Only update drawn velocity every <configured velo_frames> frames.
+ if (--skip_update == 0)
+ {
+ float length = velo_get_length();
+ s32 speed = (s32)(sqrtf(length) + 0.5f);
+ s32 speed_diff = draw_speed - speed;
+ color = speed_diff > 0 ? movie_profile.velo_font_color_inc : speed_diff < 0 ? movie_profile.velo_font_color_dec : movie_profile.velo_font_color;
+ draw_speed = speed;
+ skip_update = movie_profile.velo_frames;
+ }
char buf[128];
- s32 text_length = SVR_SNPRINTF(buf, "%d", speed);
+ s32 text_length = SVR_SNPRINTF(buf, "%d", draw_speed);
UINT16* idxs = SVR_ALLOCA_NUM(UINT16, text_length);
float* advances = SVR_ALLOCA_NUM(float, text_length);
@@ -190,7 +201,7 @@ void ProcState::velo_draw()
vid_d2d1_context->SetTransform(D2D1::Matrix3x2F::Translation(pos.x + advance_x, pos.y));
// Draw the fill.
- vid_d2d1_solid_brush->SetColor(vid_convert(movie_profile.velo_font_color));
+ vid_d2d1_solid_brush->SetColor(vid_fill_d2d1_color(color));
vid_d2d1_context->FillGeometry(geom, vid_d2d1_solid_brush);
// Draw the border.
@@ -223,7 +234,7 @@ void ProcState::velo_draw()
vid_d2d1_context->DrawGlyphRun(vid_convert(pos_copy), &run, vid_d2d1_solid_brush);
}
- vid_d2d1_solid_brush->SetColor(vid_convert(movie_profile.velo_font_color));
+ vid_d2d1_solid_brush->SetColor(vid_fill_d2d1_color(color));
vid_d2d1_context->DrawGlyphRun(vid_convert(pos), &run, vid_d2d1_solid_brush);
// vid_d2d1_solid_brush->SetColor(D2D1::ColorF(1.0f, 0.0f, 0.0f, 0.2f));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment