diff options
Diffstat (limited to 'src/hl2h.cpp')
| -rw-r--r-- | src/hl2h.cpp | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/src/hl2h.cpp b/src/hl2h.cpp index a037bac..ca7ee85 100644 --- a/src/hl2h.cpp +++ b/src/hl2h.cpp | |||
| @@ -655,13 +655,13 @@ static void install_uniform_random_hook() { | |||
| 655 | } | 655 | } |
| 656 | 656 | ||
| 657 | // --------------------------------------------------------------------------- | 657 | // --------------------------------------------------------------------------- |
| 658 | // camera / viewmodel FOV and gamma | 658 | // camera / viewmodel FOV and HDR brightness |
| 659 | // --------------------------------------------------------------------------- | 659 | // --------------------------------------------------------------------------- |
| 660 | // | 660 | // |
| 661 | // The rendered camera FOV is derived from C_BasePlayer::m_iDefaultFOV every | 661 | // The rendered camera FOV is derived from C_BasePlayer::m_iDefaultFOV every |
| 662 | // frame (CViewRender::OnRenderStart copies it into default_fov), so writing | 662 | // frame (CViewRender::OnRenderStart copies it into default_fov), so writing |
| 663 | // the client netvar is enough and needs no server command. The viewmodel FOV | 663 | // the client netvar is enough and needs no server command. The viewmodel FOV |
| 664 | // and monitor gamma are plain client cvars. | 664 | // is a plain client cvar. |
| 665 | 665 | ||
| 666 | static void view_settings_apply(void *ent) { | 666 | static void view_settings_apply(void *ent) { |
| 667 | if (g_net.default_fov >= 0 && ent) | 667 | if (g_net.default_fov >= 0 && ent) |
| @@ -673,33 +673,9 @@ static void view_settings_apply(void *ent) { | |||
| 673 | console_cmd(cmd); | 673 | console_cmd(cmd); |
| 674 | last_vm = g_fov_viewmodel; | 674 | last_vm = g_fov_viewmodel; |
| 675 | } | 675 | } |
| 676 | static int last_gamma = 22; | ||
| 677 | static int pending_gamma = -1; | ||
| 678 | if (g_gamma != last_gamma) { | ||
| 679 | char cmd[48]; | ||
| 680 | snprintf(cmd, sizeof(cmd), "mat_monitorgamma %d.%d", g_gamma / 10, | ||
| 681 | g_gamma % 10); | ||
| 682 | console_cmd(cmd); | ||
| 683 | pending_gamma = g_gamma; | ||
| 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). | ||
| 689 | float got = -1.0f; | ||
| 690 | if (g_iface.cvar) { | ||
| 691 | using FindFn = void *(*)(void *, const char *); | ||
| 692 | void *v = vfunc<FindFn>(g_iface.cvar, 12)(g_iface.cvar, | ||
| 693 | "mat_monitorgamma"); | ||
| 694 | if (v) | ||
| 695 | got = *(float *)((uintptr_t)v + 0x2c); // ConVar m_Value.f | ||
| 696 | } | ||
| 697 | logf("view: gamma request %d.%d, cvar reports %.2f", pending_gamma / 10, | ||
| 698 | pending_gamma % 10, got); | ||
| 699 | pending_gamma = -1; | ||
| 700 | } | ||
| 701 | // In-engine brightness for HDR maps. Unlike mat_monitorgamma this does not | 676 | // In-engine brightness for HDR maps. Unlike mat_monitorgamma this does not |
| 702 | // depend on the window system applying a gamma ramp. | 677 | // depend on the window system applying a gamma ramp. Fullbright bypasses |
| 678 | // tonemapping, so the slider only has a visible effect while it is off. | ||
| 703 | static int last_tonemap = 0; | 679 | static int last_tonemap = 0; |
| 704 | static int pending_tonemap = -1; | 680 | static int pending_tonemap = -1; |
| 705 | if (g_tonemap != last_tonemap) { | 681 | if (g_tonemap != last_tonemap) { |
