summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-03-14 19:36:33 +0100
committerAki <please@ignore.pl>2022-03-14 19:36:33 +0100
commit2e5d0eb1eecc52b20d1e9f7a3ce0317b851442c4 (patch)
treea1e7873c9086e5d1f4be8092d775e6127f5c388c
parent92f7c58068c6a7bfe0b32af5c1ace6bdde2f3951 (diff)
downloadstarshatter-2e5d0eb1eecc52b20d1e9f7a3ce0317b851442c4.zip
starshatter-2e5d0eb1eecc52b20d1e9f7a3ce0317b851442c4.tar.gz
starshatter-2e5d0eb1eecc52b20d1e9f7a3ce0317b851442c4.tar.bz2
Moved max texture size to GameWinDX9
-rw-r--r--Stars45/Bitmap.cpp5
-rw-r--r--Stars45/Game.cpp37
-rw-r--r--Stars45/Game.h4
-rw-r--r--Stars45/GameWinDX9.cpp38
-rw-r--r--Stars45/GameWinDX9.h7
-rw-r--r--Stars45/HUDView.cpp21
-rw-r--r--Stars45/StarSystem.cpp3
-rw-r--r--Stars45/VidDlg.cpp5
8 files changed, 64 insertions, 56 deletions
diff --git a/Stars45/Bitmap.cpp b/Stars45/Bitmap.cpp
index e69a755..865b726 100644
--- a/Stars45/Bitmap.cpp
+++ b/Stars45/Bitmap.cpp
@@ -16,6 +16,7 @@
#include "Video.h"
#include "Color.h"
#include "Game.h"
+#include "GameWinDX9.h"
// +--------------------------------------------------------------------+
@@ -664,8 +665,8 @@ Bitmap::MakeTexture()
}
// check size and aspect ratio:
- int max_tex_size = Game::GetInstance()->MaxTexSize();
- int max_tex_aspect = Game::GetInstance()->MaxTexAspect();
+ int max_tex_size = GameWinDX9::GetInstance()->MaxTexSize();
+ int max_tex_aspect = GameWinDX9::GetInstance()->MaxTexAspect();
int best_width = FindBestTexSize(width, max_tex_size);
int best_height = FindBestTexSize(height, max_tex_size);
diff --git a/Stars45/Game.cpp b/Stars45/Game.cpp
index 3d6dcb6..ff14989 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), max_tex_size(2048), screen(0), totaltime(0),
+ gamma(128), 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)
@@ -132,41 +132,6 @@ Game::SetGammaLevel(int g)
}
}
-int
-Game::MaxTexSize()
-{
- if (game && game->video) {
- int max_vid_size = game->video->MaxTexSize();
- return max_vid_size < game->max_tex_size ?
- max_vid_size : game->max_tex_size;
- }
- else if (Video::GetInstance()) {
- return Video::GetInstance()->MaxTexSize();
- }
-
- return 256;
-}
-
-int
-Game::MaxTexAspect()
-{
- if (game && game->video) {
- return game->video->MaxTexAspect();
- }
- else if (Video::GetInstance()) {
- return Video::GetInstance()->MaxTexAspect();
- }
-
- return 1;
-}
-
-void
-Game::SetMaxTexSize(int n)
-{
- if (game && n >= 64 && n <= 4096)
- game->max_tex_size = n;
-}
-
bool
Game::DisplayModeSupported(int w, int h, int bpp)
{
diff --git a/Stars45/Game.h b/Stars45/Game.h
index b42af06..49edb37 100644
--- a/Stars45/Game.h
+++ b/Stars45/Game.h
@@ -69,11 +69,8 @@ public:
static Game* GetInstance();
bool DisplayModeSupported(int w, int h, int bpp);
- int MaxTexSize();
- int MaxTexAspect();
int GammaLevel();
void SetGammaLevel(int g);
- void SetMaxTexSize(int n);
Clock* GetClock();
DWORD Frame();
@@ -122,7 +119,6 @@ protected:
SoundCard* soundcard;
Screen* screen;
int gamma;
- int max_tex_size;
RenderStats stats;
DWORD totaltime;
diff --git a/Stars45/GameWinDX9.cpp b/Stars45/GameWinDX9.cpp
index efc825a..5afff31 100644
--- a/Stars45/GameWinDX9.cpp
+++ b/Stars45/GameWinDX9.cpp
@@ -27,7 +27,8 @@ GameWinDX9::GetInstance()
}
-GameWinDX9::GameWinDX9()
+GameWinDX9::GameWinDX9() :
+ max_tex_size {2048}
{
if (instance != nullptr)
Panic::Panic("Multiple instances of GameWinDX9");
@@ -279,3 +280,38 @@ GameWinDX9::LoadPalette(PALETTEENTRY* pal, BYTE* inv)
return true;
}
+
+
+int
+GameWinDX9::MaxTexSize() const
+{
+ if (video) {
+ int max_from_video = video->MaxTexSize();
+ if (max_from_video < max_tex_size)
+ return max_from_video;
+ return max_tex_size;
+ }
+ else if (Video* video = Video::GetInstance()) {
+ return video->MaxTexSize();
+ }
+ return 256;
+}
+
+
+int
+GameWinDX9::MaxTexAspect() const
+{
+ if (video)
+ return video->MaxTexAspect();
+ else if (Video* video = Video::GetInstance())
+ return video->MaxTexAspect();
+ return 1;
+}
+
+
+void
+GameWinDX9::SetMaxTexSize(int n)
+{
+ if (n >= 64 && n <= 4096)
+ max_tex_size = n;
+}
diff --git a/Stars45/GameWinDX9.h b/Stars45/GameWinDX9.h
index 5193a77..002983a 100644
--- a/Stars45/GameWinDX9.h
+++ b/Stars45/GameWinDX9.h
@@ -27,10 +27,17 @@ public:
virtual bool SetupPalette();
virtual bool LoadPalette(PALETTEENTRY* pal, BYTE* inv);
+ int MaxTexSize() const;
+ int MaxTexAspect() const;
+
+ void SetMaxTexSize(int n);
+
protected:
PALETTEENTRY standard_palette[256];
BYTE inverse_palette[32768];
+ int max_tex_size;
+
private:
static GameWinDX9* instance;
};
diff --git a/Stars45/HUDView.cpp b/Stars45/HUDView.cpp
index 2f0ec20..f2b4b02 100644
--- a/Stars45/HUDView.cpp
+++ b/Stars45/HUDView.cpp
@@ -62,6 +62,7 @@
#include "Polygon.h"
#include "Sound.h"
#include "Game.h"
+#include "GameWinDX9.h"
#include "ContentBundle.h"
#include "Window.h"
@@ -787,7 +788,7 @@ HUDView::SetTacticalMode(int mode)
for (int i = 0; i < 31; i++)
pitch_ladder[i]->Hide();
}
- else if (Game::GetInstance()->MaxTexSize() > 128) {
+ else if (GameWinDX9::GetInstance()->MaxTexSize() > 128) {
hud_left_sprite->Show();
hud_right_sprite->Show();
}
@@ -1617,7 +1618,7 @@ HUDView::DrawPitchLadder()
for (int i = 0; i < 31; i++)
pitch_ladder[i]->Hide();
- if (ship->IsAirborne() && Game::GetInstance()->MaxTexSize() > 128) {
+ if (ship->IsAirborne() && GameWinDX9::GetInstance()->MaxTexSize() > 128) {
double xtarg = xcenter;
double ytarg = ycenter;
@@ -2648,7 +2649,7 @@ HUDView::DrawWarningPanel()
}
if (ship) {
- if (Game::GetInstance()->MaxTexSize() > 128) {
+ if (GameWinDX9::GetInstance()->MaxTexSize() > 128) {
warn_left_sprite->Show();
warn_right_sprite->Show();
}
@@ -2755,7 +2756,7 @@ HUDView::DrawInstructions()
{
if (!ship) return;
- if (Game::GetInstance()->MaxTexSize() > 128) {
+ if (GameWinDX9::GetInstance()->MaxTexSize() > 128) {
instr_left_sprite->Show();
instr_right_sprite->Show();
}
@@ -3728,7 +3729,7 @@ HUDView::ExecFrame()
}
if (!tactical) {
- if (Game::GetInstance()->MaxTexSize() > 128) {
+ if (GameWinDX9::GetInstance()->MaxTexSize() > 128) {
hud_left_sprite->Show();
hud_right_sprite->Show();
}
@@ -3939,7 +3940,7 @@ HUDView::RestoreHUD()
icon_target_sprite->Hide();
}
- if (!tactical && Game::GetInstance()->MaxTexSize() > 128) {
+ if (!tactical && GameWinDX9::GetInstance()->MaxTexSize() > 128) {
hud_left_sprite->Show();
hud_right_sprite->Show();
}
@@ -4040,7 +4041,7 @@ HUDView::SetHUDColorSet(int c)
ColorizeBitmap(cross3, cross3_shade, hud_color, true);
ColorizeBitmap(cross4, cross4_shade, hud_color, true);
- if (Game::GetInstance()->MaxTexSize() > 128) {
+ if (GameWinDX9::GetInstance()->MaxTexSize() > 128) {
ColorizeBitmap(hud_left_air, hud_left_shade_air, hud_color);
ColorizeBitmap(hud_right_air, hud_right_shade_air, hud_color);
ColorizeBitmap(hud_left_fighter, hud_left_shade_fighter, hud_color);
@@ -4187,10 +4188,10 @@ HUDView::ColorizeBitmap(Bitmap& img, BYTE* shades, Color color, bool force_alpha
{
if (!shades) return;
- int max_tex_size = Game::GetInstance()->MaxTexSize();
+ int max_tex_size = GameWinDX9::GetInstance()->MaxTexSize();
if (max_tex_size < 128)
- Game::GetInstance()->SetMaxTexSize(128);
+ GameWinDX9::GetInstance()->SetMaxTexSize(128);
if (hud_view && hud_view->cockpit_hud_texture && !force_alpha) {
img.FillColor(Color::Black);
@@ -4217,7 +4218,7 @@ HUDView::ColorizeBitmap(Bitmap& img, BYTE* shades, Color color, bool force_alpha
}
if (max_tex_size < 128)
- Game::GetInstance()->SetMaxTexSize(max_tex_size);
+ GameWinDX9::GetInstance()->SetMaxTexSize(max_tex_size);
}
// +--------------------------------------------------------------------+
diff --git a/Stars45/StarSystem.cpp b/Stars45/StarSystem.cpp
index e78d970..a321afd 100644
--- a/Stars45/StarSystem.cpp
+++ b/Stars45/StarSystem.cpp
@@ -21,6 +21,7 @@
#include "Weather.h"
#include "Game.h"
+#include "GameWinDX9.h"
#include "Sound.h"
#include "Solid.h"
#include "Light.h"
@@ -1093,7 +1094,7 @@ StarSystem::CreateBody(OrbitalBody& body)
Text surface = body.tex_name;
Text glow = body.tex_glow;
- if (Game::GetInstance()->MaxTexSize() >= 512) {
+ if (GameWinDX9::GetInstance()->MaxTexSize() >= 512) {
if (body.tex_high_res.length())
surface = body.tex_high_res;
diff --git a/Stars45/VidDlg.cpp b/Stars45/VidDlg.cpp
index 2a68f86..d205541 100644
--- a/Stars45/VidDlg.cpp
+++ b/Stars45/VidDlg.cpp
@@ -12,6 +12,7 @@
*/
#include "Game.h"
+#include "GameWinDX9.h"
#include "MemDebug.h"
#include "VidDlg.h"
#include "BaseScreen.h"
@@ -141,7 +142,7 @@ VidDlg::Show()
selected_render = 9;
selected_card = 0;
- int n = stars->MaxTexSize();
+ int n = GameWinDX9::GetInstance()->MaxTexSize();
for (int i = 0; i < 7; i++) {
if (n <= pow(2.0f, i+6)) {
@@ -392,7 +393,7 @@ VidDlg::Apply()
d = 32;
}
- if (Game::GetInstance()->MaxTexSize() != t)
+ if (GameWinDX9::GetInstance()->MaxTexSize() != t)
video_change = true;
}