summaryrefslogtreecommitdiffstats
path: root/src/hl2h.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hl2h.cpp')
-rw-r--r--src/hl2h.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/hl2h.cpp b/src/hl2h.cpp
index f7106cd..1fc7096 100644
--- a/src/hl2h.cpp
+++ b/src/hl2h.cpp
@@ -674,13 +674,18 @@ static void view_settings_apply(void *ent) {
674 last_vm = g_fov_viewmodel; 674 last_vm = g_fov_viewmodel;
675 } 675 }
676 static int last_gamma = 22; 676 static int last_gamma = 22;
677 static int pending_gamma = -1;
677 if (g_gamma != last_gamma) { 678 if (g_gamma != last_gamma) {
678 char cmd[48]; 679 char cmd[48];
679 snprintf(cmd, sizeof(cmd), "mat_monitorgamma %d.%d", g_gamma / 10, 680 snprintf(cmd, sizeof(cmd), "mat_monitorgamma %d.%d", g_gamma / 10,
680 g_gamma % 10); 681 g_gamma % 10);
681 console_cmd(cmd); 682 console_cmd(cmd);
682 // Read back through ICvar to tell an ignored command from an OS gamma 683 pending_gamma = g_gamma;
683 // ramp that the compositor discards. 684 last_gamma = g_gamma;
685 }
686 if (pending_gamma >= 0) {
687 // ClientCmd is queued, so read the cvar on the next tick to see the value
688 // the engine actually accepted (it clamps mat_monitorgamma at 2.6).
684 float got = -1.0f; 689 float got = -1.0f;
685 if (g_iface.cvar) { 690 if (g_iface.cvar) {
686 using FindFn = void *(*)(void *, const char *); 691 using FindFn = void *(*)(void *, const char *);
@@ -689,9 +694,9 @@ static void view_settings_apply(void *ent) {
689 if (v) 694 if (v)
690 got = *(float *)((uintptr_t)v + 0x2c); // ConVar m_Value.f 695 got = *(float *)((uintptr_t)v + 0x2c); // ConVar m_Value.f
691 } 696 }
692 logf("view: gamma request %d.%d, cvar reports %.2f", g_gamma / 10, 697 logf("view: gamma request %d.%d, cvar reports %.2f", pending_gamma / 10,
693 g_gamma % 10, got); 698 pending_gamma % 10, got);
694 last_gamma = g_gamma; 699 pending_gamma = -1;
695 } 700 }
696} 701}
697 702