summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui.cpp25
-rw-r--r--src/hl2h.cpp32
-rw-r--r--src/hl2h.h1
-rw-r--r--src/menu.cpp11
4 files changed, 9 insertions, 60 deletions
diff --git a/src/gui.cpp b/src/gui.cpp
index 83dc0a5..59c4364 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -411,20 +411,17 @@ static void build_cards() {
411 g_ctrls[g_nctrl - 1].zero_unlimited = true; 411 g_ctrls[g_nctrl - 1].zero_unlimited = true;
412 412
413 int view = add_card(2, nullptr, "Camera / display", 413 int view = add_card(2, nullptr, "Camera / display",
414 "Camera FOV, viewmodel FOV and monitor gamma.", true); 414 "Camera FOV, viewmodel FOV and HDR brightness.", true);
415 add_slider(view, "Camera FOV", 415 add_slider(view, "Camera FOV",
416 "World camera field of view (40-140; stock 75).", 40, 140, 416 "World camera field of view (40-140; stock 75).", 40, 140,
417 &g_fov_camera); 417 &g_fov_camera);
418 add_slider(view, "Viewmodel FOV", 418 add_slider(view, "Viewmodel FOV",
419 "Weapon model field of view (20-120; stock 54).", 20, 120, 419 "Weapon model field of view (20-120; stock 54).", 20, 120,
420 &g_fov_viewmodel); 420 &g_fov_viewmodel);
421 add_slider(view, "Gamma x10",
422 "mat_monitorgamma x10: 16 = 1.6, 26 = 2.6 (engine max), stock "
423 "is 22. Uses the OS gamma ramp; some compositors ignore it.",
424 16, 26, &g_gamma);
425 add_slider(view, "HDR brightness", 421 add_slider(view, "HDR brightness",
426 "mat_force_tonemap_scale x10 (0 = automatic). In-engine " 422 "mat_force_tonemap_scale x10 (0 = automatic). In-engine "
427 "brightness for HDR maps; 10 = 1.0.", 423 "brightness for HDR maps; 10 = 1.0. No effect while Fullbright "
424 "is on.",
428 0, 30, &g_tonemap); 425 0, 30, &g_tonemap);
429 426
430 add_card(2, &g_fullbright, "Fullbright", 427 add_card(2, &g_fullbright, "Fullbright",
@@ -2245,22 +2242,6 @@ SDL_WarpMouseGlobal(int x, int y) {
2245 real_warp_global(x, y); 2242 real_warp_global(x, y);
2246} 2243}
2247 2244
2248// Diagnostic: tell whether mat_monitorgamma reaches the SDL gamma ramp at all.
2249static int (*real_set_gamma_ramp)(void *, const unsigned short *,
2250 const unsigned short *,
2251 const unsigned short *) = nullptr;
2252
2253extern "C" __attribute__((visibility("default"))) int
2254SDL_SetWindowGammaRamp(void *window, const unsigned short *r,
2255 const unsigned short *g, const unsigned short *b) {
2256 if (!real_set_gamma_ramp)
2257 real_set_gamma_ramp = (int (*)(void *, const unsigned short *,
2258 const unsigned short *,
2259 const unsigned short *))dlsym(
2260 RTLD_NEXT, "SDL_SetWindowGammaRamp");
2261 return real_set_gamma_ramp ? real_set_gamma_ramp(window, r, g, b) : -1;
2262}
2263
2264static unsigned int (*real_get_rel_mouse)(int *, int *) = nullptr; 2245static unsigned int (*real_get_rel_mouse)(int *, int *) = nullptr;
2265static int (*real_poll_event)(void *) = nullptr; 2246static int (*real_poll_event)(void *) = nullptr;
2266 2247
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
666static void view_settings_apply(void *ent) { 666static 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) {
diff --git a/src/hl2h.h b/src/hl2h.h
index a050feb..f1e72be 100644
--- a/src/hl2h.h
+++ b/src/hl2h.h
@@ -248,7 +248,6 @@ extern bool g_auto_crouchjump;
248extern bool g_edge_jump; 248extern bool g_edge_jump;
249extern int g_fov_camera; 249extern int g_fov_camera;
250extern int g_fov_viewmodel; 250extern int g_fov_viewmodel;
251extern int g_gamma;
252extern int g_tonemap; 251extern int g_tonemap;
253extern int g_esp_col_hostile[3]; 252extern int g_esp_col_hostile[3];
254extern int g_esp_col_neutral[3]; 253extern int g_esp_col_neutral[3];
diff --git a/src/menu.cpp b/src/menu.cpp
index 033c0f9..020d2c5 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -81,7 +81,6 @@ bool g_auto_crouchjump = false;
81bool g_edge_jump = false; 81bool g_edge_jump = false;
82int g_fov_camera = 75; // HL2's stock camera FOV 82int g_fov_camera = 75; // HL2's stock camera FOV
83int g_fov_viewmodel = 54; // HL2's stock viewmodel FOV 83int g_fov_viewmodel = 54; // HL2's stock viewmodel FOV
84int g_gamma = 22; // mat_monitorgamma x10, stock 2.2
85int g_tonemap = 0; // mat_force_tonemap_scale x10, 0 = automatic 84int g_tonemap = 0; // mat_force_tonemap_scale x10, 0 = automatic
86int g_esp_col_hostile[3] = {255, 60, 60}; 85int g_esp_col_hostile[3] = {255, 60, 60};
87int g_esp_col_neutral[3] = {220, 220, 220}; 86int g_esp_col_neutral[3] = {220, 220, 220};
@@ -249,8 +248,8 @@ void config_save() {
249 g_esp_col_neutral[0], g_esp_col_neutral[1], g_esp_col_neutral[2], 248 g_esp_col_neutral[0], g_esp_col_neutral[1], g_esp_col_neutral[2],
250 g_esp_col_friendly[0], g_esp_col_friendly[1], 249 g_esp_col_friendly[0], g_esp_col_friendly[1],
251 g_esp_col_friendly[2]); 250 g_esp_col_friendly[2]);
252 fprintf(f, "[view]\nfov=%d\nvmfov=%d\ngamma=%d\ntonemap=%d\n", 251 fprintf(f, "[view]\nfov=%d\nvmfov=%d\ntonemap=%d\n", g_fov_camera,
253 g_fov_camera, g_fov_viewmodel, g_gamma, g_tonemap); 252 g_fov_viewmodel, g_tonemap);
254 fprintf(f, "[movement]\ncrouchjump=%d\nedgejump=%d\n", 253 fprintf(f, "[movement]\ncrouchjump=%d\nedgejump=%d\n",
255 (int)g_auto_crouchjump, (int)g_edge_jump); 254 (int)g_auto_crouchjump, (int)g_edge_jump);
256 gui_config_write(f); 255 gui_config_write(f);
@@ -405,11 +404,6 @@ static bool config_load() {
405 lo = 20; 404 lo = 20;
406 hi = 120; 405 hi = 120;
407 stock = 54; 406 stock = 54;
408 } else if (strcmp(key, "gamma") == 0) {
409 dst = &g_gamma;
410 lo = 16;
411 hi = 26; // the engine clamps mat_monitorgamma at 2.6
412 stock = 22;
413 } else if (strcmp(key, "tonemap") == 0) { 407 } else if (strcmp(key, "tonemap") == 0) {
414 dst = &g_tonemap; 408 dst = &g_tonemap;
415 lo = 0; 409 lo = 0;
@@ -610,7 +604,6 @@ void config_reset_defaults() {
610 g_edge_jump = false; 604 g_edge_jump = false;
611 g_fov_camera = 75; 605 g_fov_camera = 75;
612 g_fov_viewmodel = 54; 606 g_fov_viewmodel = 54;
613 g_gamma = 22;
614 g_tonemap = 0; 607 g_tonemap = 0;
615 g_esp_col_hostile[0] = 255; 608 g_esp_col_hostile[0] = 255;
616 g_esp_col_hostile[1] = 60; 609 g_esp_col_hostile[1] = 60;