From dac5158376875636306610365dc1b9820a18a277 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 16 Mar 2022 21:30:41 +0100 Subject: Removed gamma level management from Game and Starshatter classes --- Stars45/Game.cpp | 25 +------------------------ Stars45/Game.h | 3 --- Stars45/GameWinDX9.cpp | 2 -- Stars45/Starshatter.cpp | 6 +++--- Stars45/VidDlg.cpp | 17 ++++++++--------- Stars45/VidDlg.h | 1 + Stars45/VideoDX9.cpp | 2 ++ Stars45/VideoSettings.cpp | 7 +++++++ Stars45/VideoSettings.h | 2 ++ 9 files changed, 24 insertions(+), 41 deletions(-) (limited to 'Stars45') diff --git a/Stars45/Game.cpp b/Stars45/Game.cpp index ff14989..24d6871 100644 --- a/Stars45/Game.cpp +++ b/Stars45/Game.cpp @@ -37,7 +37,7 @@ const double MAX_FRAME_TIME_NORMAL = 1.0 / 5.0; Game::Game() : world(0), video_factory(0), video(0), video_settings(0), soundcard(0), - gamma(128), screen(0), totaltime(0), + screen(0), totaltime(0), hInst(0), hwnd(0), frame_rate(0), frame_count(0), frame_count0(0), frame_time(0), frame_time0(0), status(Game::OK), exit_code(0), window_style(0) @@ -112,26 +112,6 @@ bool Game::IsWindowed() // +--------------------------------------------------------------------+ -int -Game::GammaLevel() -{ - if (game) - return game->gamma; - - return 0; -} - -void -Game::SetGammaLevel(int g) -{ - if (game) { - game->gamma = g; - - if (game->video) - game->video->SetGammaLevel(g); - } -} - bool Game::DisplayModeSupported(int w, int h, int bpp) { @@ -251,7 +231,6 @@ Game::ResetVideo() Print(" WARNING: could not set video background color to Black\n"); screen->ClearAllFrames(true); - video->SetGammaLevel(gamma); Print(" Re-established requested video parameters.\n"); @@ -448,8 +427,6 @@ Game::InitGame() Print(" WARNING: could not set video background color to Black\n"); screen->ClearAllFrames(true); - video->SetGammaLevel(gamma); - Print(" Established requested video parameters.\n\n"); } diff --git a/Stars45/Game.h b/Stars45/Game.h index 49edb37..e181b9b 100644 --- a/Stars45/Game.h +++ b/Stars45/Game.h @@ -69,8 +69,6 @@ public: static Game* GetInstance(); bool DisplayModeSupported(int w, int h, int bpp); - int GammaLevel(); - void SetGammaLevel(int g); Clock* GetClock(); DWORD Frame(); @@ -118,7 +116,6 @@ protected: VideoSettings* video_settings; SoundCard* soundcard; Screen* screen; - int gamma; RenderStats stats; DWORD totaltime; diff --git a/Stars45/GameWinDX9.cpp b/Stars45/GameWinDX9.cpp index 5afff31..65cf2a0 100644 --- a/Stars45/GameWinDX9.cpp +++ b/Stars45/GameWinDX9.cpp @@ -76,8 +76,6 @@ GameWinDX9::Init(HINSTANCE hi, HINSTANCE hpi, LPSTR cmdline, int nCmdShow) Panic::Panic(" Insufficient DirectX detected (Dx9 IS REQUIRED)"); status = INIT_FAILED; } - - Print(" Gamma Level = %d\n", gamma); } if (status == OK) { diff --git a/Stars45/Starshatter.cpp b/Stars45/Starshatter.cpp index eeb5f6d..28f1506 100644 --- a/Stars45/Starshatter.cpp +++ b/Stars45/Starshatter.cpp @@ -165,8 +165,6 @@ chat_mode(0), exit_time(1.2), cutscene(0) title_text = "STARSHATTER"; palette_name = "alpha"; - gamma = 128; // default - flat gamma ramp - if (!DataLoader::GetLoader()) DataLoader::Initialize(); @@ -2351,6 +2349,7 @@ Starshatter::LoadVideoConfig(const char* filename) int screen_width = 1280; int screen_height = 720; int screen_depth = 32; + int gamma = 128; int terrain_detail_level = 3; bool shadows_enabled = true; bool spec_maps_enabled = true; @@ -2575,6 +2574,7 @@ Starshatter::LoadVideoConfig(const char* filename) else video_settings->fullscreen_mode.format = VideoMode::FMT_X8R8G8B8; + video_settings->gamma = gamma; video_settings->shadows = shadows_enabled; video_settings->specmaps = spec_maps_enabled; video_settings->bumpmaps = bump_maps_enabled; @@ -2607,7 +2607,7 @@ Starshatter::SaveVideoConfig(const char* filename) fprintf(f, "\n"); fprintf(f, "max_tex: %4d\n", max_tex_size); fprintf(f, "primary3D: %s\n", "true"); - fprintf(f, "gamma: %4d\n", gamma); + fprintf(f, "gamma: %4d\n", video_settings->gamma); fprintf(f, "\n"); fprintf(f, "terrain_detail_level: %d\n", Terrain::DetailLevel()); fprintf(f, "terrain_texture_enable: %true\n"); diff --git a/Stars45/VidDlg.cpp b/Stars45/VidDlg.cpp index d205541..0d6fe9a 100644 --- a/Stars45/VidDlg.cpp +++ b/Stars45/VidDlg.cpp @@ -50,7 +50,7 @@ DEF_MAP_CLIENT(VidDlg, OnMod); VidDlg::VidDlg(Screen* s, FormDef& def, BaseScreen* mgr) : FormWindow(s, 0, 0, s->Width(), s->Height()), manager(mgr), -selected_mode(0), selected_detail(0), orig_gamma(128), +selected_mode(0), selected_detail(0), new_gamma(128), orig_gamma(128), selected_card(0), selected_tex_size(0), selected_render(0), selected_texture(0), mode(0), tex_size(0), detail(0), texture(0), gamma(0), shadows(0), spec_maps(0), bump_maps(0), lens_flare(0), corona(0), nebula(0), dust(0), @@ -60,7 +60,7 @@ closed(true) stars = Starshatter::GetInstance(); Init(def); - orig_gamma = Game::GetInstance()->GammaLevel(); + orig_gamma = Video::GetInstance()->GammaLevel(); } VidDlg::~VidDlg() @@ -197,9 +197,8 @@ VidDlg::Show() if (texture) texture->SetSelection(selected_texture); - if (gamma) { - orig_gamma = Game::GetInstance()->GammaLevel(); + orig_gamma = Video::GetInstance()->GammaLevel(); gamma->SetValue(orig_gamma); } } @@ -253,9 +252,9 @@ void VidDlg::OnGamma(AWEvent* event) { int g = gamma->GetValue(); - if (g >= 0 && g <= 255) { - Game::GetInstance()->SetGammaLevel(g); + new_gamma = g; + Video::GetInstance()->SetGammaLevel(g); } } @@ -405,7 +404,7 @@ VidDlg::Apply() fopen_s(&f, "video.cfg", "wb"); if (gamma) { - g = gamma->GetValue(); + new_gamma = gamma->GetValue(); } if (f) { @@ -416,7 +415,7 @@ VidDlg::Apply() fprintf(f, "\n"); fprintf(f, "max_tex: %d\n", (int) pow(2.0f, 6 + selected_tex_size)); fprintf(f, "primary3D: %s\n", (a>0)?"true":"false"); - fprintf(f, "gamma: %4d\n", g); + fprintf(f, "gamma: %4d\n", new_gamma); fprintf(f, "\n"); fprintf(f, "terrain_detail_level: %d\n", selected_detail + 2); fprintf(f, "terrain_texture_enable: %s\n", selected_texture ? "true" : "false"); @@ -452,7 +451,7 @@ VidDlg::Apply() void VidDlg::Cancel() { - Game::GetInstance()->SetGammaLevel(orig_gamma); + Video::GetInstance()->SetGammaLevel(orig_gamma); closed = true; } diff --git a/Stars45/VidDlg.h b/Stars45/VidDlg.h index 6ec0c1a..0b6e918 100644 --- a/Stars45/VidDlg.h +++ b/Stars45/VidDlg.h @@ -96,6 +96,7 @@ protected: int selected_mode; int selected_detail; int selected_texture; + int new_gamma; int orig_gamma; bool closed; diff --git a/Stars45/VideoDX9.cpp b/Stars45/VideoDX9.cpp index 2f2b356..ecc0332 100644 --- a/Stars45/VideoDX9.cpp +++ b/Stars45/VideoDX9.cpp @@ -386,6 +386,8 @@ magic_fx(0), magic_fx_code(0), magic_fx_code_len(0) render_state[TEXTURE_WRAP] = true; render_state[LIGHTING_PASS] = 0; + SetGammaLevel(video_settings.GetGammaLevel()); + ZeroMemory(&rect, sizeof(rect)); if (!texcache) diff --git a/Stars45/VideoSettings.cpp b/Stars45/VideoSettings.cpp index f7c1833..c56dddb 100644 --- a/Stars45/VideoSettings.cpp +++ b/Stars45/VideoSettings.cpp @@ -31,6 +31,7 @@ VideoSettings::VideoSettings() window_width = 1280; window_height = 720; + gamma = 128; is_windowed = false; use_effects = true; shadows = true; @@ -47,6 +48,12 @@ VideoSettings::~VideoSettings() // +--------------------------------------------------------------------+ +int +VideoSettings::GetGammaLevel() const +{ + return gamma; +} + bool VideoSettings::IsWindowed() const { diff --git a/Stars45/VideoSettings.h b/Stars45/VideoSettings.h index 2520126..b9e74e4 100644 --- a/Stars45/VideoSettings.h +++ b/Stars45/VideoSettings.h @@ -84,6 +84,7 @@ public: // accessor methods + int GetGammaLevel() const; bool IsWindowed() const; bool UseEffects() const; int GetWidth() const; @@ -106,6 +107,7 @@ public: // properties + int gamma; bool is_windowed; bool use_effects; VideoMode fullscreen_mode; -- cgit v1.1