summaryrefslogtreecommitdiffhomepage
path: root/StarsEx
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-10 00:30:31 +0200
committerAki <please@ignore.pl>2022-04-10 00:30:31 +0200
commit06683d2e60da5144e5483c3d0cf88aa28dab1c8a (patch)
tree646b470948b93a1dd18ba759f071ff454211feb1 /StarsEx
parent595140fc96fc48ac6934615d37bd2b4a180d716d (diff)
downloadstarshatter-06683d2e60da5144e5483c3d0cf88aa28dab1c8a.zip
starshatter-06683d2e60da5144e5483c3d0cf88aa28dab1c8a.tar.gz
starshatter-06683d2e60da5144e5483c3d0cf88aa28dab1c8a.tar.bz2
Requested texture size is now managed by Video and Video Settings
Diffstat (limited to 'StarsEx')
-rw-r--r--StarsEx/Bitmap.cpp5
-rw-r--r--StarsEx/GameWinDX9.cpp36
-rw-r--r--StarsEx/GameWinDX9.h5
-rw-r--r--StarsEx/HUDView.cpp22
-rw-r--r--StarsEx/StarSystem.cpp3
-rw-r--r--StarsEx/Starshatter.cpp6
-rw-r--r--StarsEx/VidDlg.cpp5
-rw-r--r--StarsEx/Video.h2
-rw-r--r--StarsEx/VideoDX9.cpp16
-rw-r--r--StarsEx/VideoDX9.h3
-rw-r--r--StarsEx/VideoSettings.cpp7
-rw-r--r--StarsEx/VideoSettings.h2
12 files changed, 49 insertions, 63 deletions
diff --git a/StarsEx/Bitmap.cpp b/StarsEx/Bitmap.cpp
index 70cff64..07c5dae 100644
--- a/StarsEx/Bitmap.cpp
+++ b/StarsEx/Bitmap.cpp
@@ -15,7 +15,6 @@
#include "Clock.h"
#include "Video.h"
#include "Color.h"
-#include "GameWinDX9.h"
// +--------------------------------------------------------------------+
@@ -664,8 +663,8 @@ Bitmap::MakeTexture()
}
// check size and aspect ratio:
- int max_tex_size = GameWinDX9::GetInstance()->MaxTexSize();
- int max_tex_aspect = GameWinDX9::GetInstance()->MaxTexAspect();
+ int max_tex_size = Video::GetInstance()->TexSize();
+ int max_tex_aspect = Video::GetInstance()->MaxTexAspect();
int best_width = FindBestTexSize(width, max_tex_size);
int best_height = FindBestTexSize(height, max_tex_size);
diff --git a/StarsEx/GameWinDX9.cpp b/StarsEx/GameWinDX9.cpp
index 9571122..d49dfdb 100644
--- a/StarsEx/GameWinDX9.cpp
+++ b/StarsEx/GameWinDX9.cpp
@@ -35,7 +35,6 @@ GameWinDX9::GetInstance()
GameWinDX9::GameWinDX9() :
- max_tex_size {2048},
screen_color {Color::Black},
hInst {nullptr},
hwnd {nullptr},
@@ -641,33 +640,6 @@ GameWinDX9::ShowStats()
}
-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;
-}
-
-
Color
GameWinDX9::GetScreenColor() const
{
@@ -708,14 +680,6 @@ GameWinDX9::GetHWND()
void
-GameWinDX9::SetMaxTexSize(int n)
-{
- if (n >= 64 && n <= 4096)
- max_tex_size = n;
-}
-
-
-void
GameWinDX9::SetScreenColor(Color c)
{
screen_color = c;
diff --git a/StarsEx/GameWinDX9.h b/StarsEx/GameWinDX9.h
index c6862da..065db57 100644
--- a/StarsEx/GameWinDX9.h
+++ b/StarsEx/GameWinDX9.h
@@ -46,8 +46,6 @@ public:
virtual void Pause(bool f) override;
void ShowStats();
- int MaxTexSize() const;
- int MaxTexAspect() const;
Color GetScreenColor() const;
int GetScreenWidth() const;
int GetScreenHeight() const;
@@ -55,17 +53,14 @@ public:
HINSTANCE GetHINST();
HWND GetHWND();
- void SetMaxTexSize(int n);
void SetScreenColor(Color c);
-
protected:
friend LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM uParam, LPARAM lParam);
PALETTEENTRY standard_palette[256];
BYTE inverse_palette[32768];
- int max_tex_size;
Color screen_color;
HINSTANCE hInst;
diff --git a/StarsEx/HUDView.cpp b/StarsEx/HUDView.cpp
index c280333..595bc38 100644
--- a/StarsEx/HUDView.cpp
+++ b/StarsEx/HUDView.cpp
@@ -62,9 +62,9 @@
#include "Sound.h"
#include "Game.h"
#include "Clock.h"
-#include "GameWinDX9.h"
#include "ContentBundle.h"
#include "Window.h"
+#include "Video.h"
static Bitmap hud_left_air;
static Bitmap hud_right_air;
@@ -788,7 +788,7 @@ HUDView::SetTacticalMode(int mode)
for (int i = 0; i < 31; i++)
pitch_ladder[i]->Hide();
}
- else if (GameWinDX9::GetInstance()->MaxTexSize() > 128) {
+ else if (Video::GetInstance()->TexSize() > 128) {
hud_left_sprite->Show();
hud_right_sprite->Show();
}
@@ -1618,7 +1618,7 @@ HUDView::DrawPitchLadder()
for (int i = 0; i < 31; i++)
pitch_ladder[i]->Hide();
- if (ship->IsAirborne() && GameWinDX9::GetInstance()->MaxTexSize() > 128) {
+ if (ship->IsAirborne() && Video::GetInstance()->TexSize() > 128) {
double xtarg = xcenter;
double ytarg = ycenter;
@@ -2649,7 +2649,7 @@ HUDView::DrawWarningPanel()
}
if (ship) {
- if (GameWinDX9::GetInstance()->MaxTexSize() > 128) {
+ if (Video::GetInstance()->TexSize() > 128) {
warn_left_sprite->Show();
warn_right_sprite->Show();
}
@@ -2756,7 +2756,7 @@ HUDView::DrawInstructions()
{
if (!ship) return;
- if (GameWinDX9::GetInstance()->MaxTexSize() > 128) {
+ if (Video::GetInstance()->TexSize() > 128) {
instr_left_sprite->Show();
instr_right_sprite->Show();
}
@@ -3729,7 +3729,7 @@ HUDView::ExecFrame()
}
if (!tactical) {
- if (GameWinDX9::GetInstance()->MaxTexSize() > 128) {
+ if (Video::GetInstance()->TexSize() > 128) {
hud_left_sprite->Show();
hud_right_sprite->Show();
}
@@ -3940,7 +3940,7 @@ HUDView::RestoreHUD()
icon_target_sprite->Hide();
}
- if (!tactical && GameWinDX9::GetInstance()->MaxTexSize() > 128) {
+ if (!tactical && Video::GetInstance()->TexSize() > 128) {
hud_left_sprite->Show();
hud_right_sprite->Show();
}
@@ -4041,7 +4041,7 @@ HUDView::SetHUDColorSet(int c)
ColorizeBitmap(cross3, cross3_shade, hud_color, true);
ColorizeBitmap(cross4, cross4_shade, hud_color, true);
- if (GameWinDX9::GetInstance()->MaxTexSize() > 128) {
+ if (Video::GetInstance()->TexSize() > 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);
@@ -4188,10 +4188,10 @@ HUDView::ColorizeBitmap(Bitmap& img, BYTE* shades, Color color, bool force_alpha
{
if (!shades) return;
- int max_tex_size = GameWinDX9::GetInstance()->MaxTexSize();
+ int max_tex_size = Video::GetInstance()->TexSize();
if (max_tex_size < 128)
- GameWinDX9::GetInstance()->SetMaxTexSize(128);
+ Video::GetInstance()->RequestTexSize(128);
if (hud_view && hud_view->cockpit_hud_texture && !force_alpha) {
img.FillColor(Color::Black);
@@ -4218,7 +4218,7 @@ HUDView::ColorizeBitmap(Bitmap& img, BYTE* shades, Color color, bool force_alpha
}
if (max_tex_size < 128)
- GameWinDX9::GetInstance()->SetMaxTexSize(max_tex_size);
+ Video::GetInstance()->RequestTexSize(max_tex_size);
}
// +--------------------------------------------------------------------+
diff --git a/StarsEx/StarSystem.cpp b/StarsEx/StarSystem.cpp
index b31f577..4409023 100644
--- a/StarsEx/StarSystem.cpp
+++ b/StarsEx/StarSystem.cpp
@@ -29,6 +29,7 @@
#include "DataLoader.h"
#include "Scene.h"
#include "ParseUtil.h"
+#include "Video.h"
const long double epoch = 0.5e9;
long double StarSystem::stardate = 0;
@@ -1094,7 +1095,7 @@ StarSystem::CreateBody(OrbitalBody& body)
Text surface = body.tex_name;
Text glow = body.tex_glow;
- if (GameWinDX9::GetInstance()->MaxTexSize() >= 512) {
+ if (Video::GetInstance()->TexSize() >= 512) {
if (body.tex_high_res.length())
surface = body.tex_high_res;
diff --git a/StarsEx/Starshatter.cpp b/StarsEx/Starshatter.cpp
index 894644b..62b728f 100644
--- a/StarsEx/Starshatter.cpp
+++ b/StarsEx/Starshatter.cpp
@@ -2284,8 +2284,7 @@ Starshatter::LoadVideoConfig(const char* filename)
bool vertex_shader = true;
bool pixel_shader = true;
float depth_bias = video_settings->depth_bias;
-
- max_tex_size = 2048;
+ int max_tex_size = 2048;
if (MachineInfo::GetCpuSpeed() >= 1000 && MachineInfo::GetTotalRam() > 128)
terrain_detail_level = 4;
@@ -2508,6 +2507,7 @@ Starshatter::LoadVideoConfig(const char* filename)
video_settings->enable_vs = vertex_shader;
video_settings->enable_ps = pixel_shader;
video_settings->depth_bias = depth_bias;
+ video_settings->tex_size = max_tex_size;
}
if (video) {
@@ -2532,7 +2532,7 @@ Starshatter::SaveVideoConfig(const char* filename)
fprintf(f, "height: %4d\n", video_settings->fullscreen_mode.height);
fprintf(f, "depth: %4d\n", video_settings->fullscreen_mode.format == VideoMode::FMT_R5G6B5 ? 16 : 32);
fprintf(f, "\n");
- fprintf(f, "max_tex: %4d\n", max_tex_size);
+ fprintf(f, "max_tex: %4d\n", video_settings->tex_size);
fprintf(f, "primary3D: %s\n", "true");
fprintf(f, "gamma: %4d\n", video_settings->gamma);
fprintf(f, "\n");
diff --git a/StarsEx/VidDlg.cpp b/StarsEx/VidDlg.cpp
index 8a4e4ed..1cf193b 100644
--- a/StarsEx/VidDlg.cpp
+++ b/StarsEx/VidDlg.cpp
@@ -11,7 +11,6 @@
Main Menu Dialog Active Window class
*/
-#include "GameWinDX9.h"
#include "VidDlg.h"
#include "BaseScreen.h"
#include "Starshatter.h"
@@ -140,7 +139,7 @@ VidDlg::Show()
selected_render = 9;
selected_card = 0;
- int n = GameWinDX9::GetInstance()->MaxTexSize();
+ int n = Video::GetInstance()->TexSize();
for (int i = 0; i < 7; i++) {
if (n <= pow(2.0f, i+6)) {
@@ -390,7 +389,7 @@ VidDlg::Apply()
d = 32;
}
- if (GameWinDX9::GetInstance()->MaxTexSize() != t)
+ if (Video::GetInstance()->TexSize() != t)
video_change = true;
}
diff --git a/StarsEx/Video.h b/StarsEx/Video.h
index a35a32e..8729581 100644
--- a/StarsEx/Video.h
+++ b/StarsEx/Video.h
@@ -151,6 +151,8 @@ public:
virtual int ZDepth() const { return 0; }
virtual DWORD VidMemFree() const { return 0; }
virtual int D3DLevel() const { return 0; }
+ virtual void RequestTexSize(int size) { }
+ virtual int TexSize() const { return 256; }
virtual int MaxTexSize() const { return 256; }
virtual int MaxTexAspect() const { return 0; }
virtual int GammaLevel() const { return 190; }
diff --git a/StarsEx/VideoDX9.cpp b/StarsEx/VideoDX9.cpp
index c4dd09f..06a02a0 100644
--- a/StarsEx/VideoDX9.cpp
+++ b/StarsEx/VideoDX9.cpp
@@ -242,7 +242,7 @@ static VideoDX9* video_dx9_instance = 0;
VideoDX9::VideoDX9(const HWND& window, VideoSettings* vs)
: width(0), height(0), bpp(0), hwnd(window), surface(0),
d3d(0), d3ddevice(0), device_lost(false), fade(0),
-zdepth(0), gamma(128), num_verts(0), first_vert(0),
+zdepth(0), gamma(128), requested_tex_size(2048), num_verts(0), first_vert(0),
current_texture(0), screen_vbuf(0), screen_ibuf(0),
font_verts(0), font_indices(0), font_nverts(0),
nlights(0), use_material(0), d3dx_font(0),
@@ -365,6 +365,7 @@ magic_fx(0), magic_fx_code(0), magic_fx_code_len(0)
width = video_settings.GetWidth();
height = video_settings.GetHeight();
bpp = video_settings.GetDepth();
+ requested_tex_size = video_settings.GetTexSize();
shadow_enabled = vs->shadows;
bump_enabled = vs->bumpmaps;
@@ -742,6 +743,19 @@ VideoDX9::VidMemFree() const
return result;
}
+void
+VideoDX9::RequestTexSize(int size)
+{
+ requested_tex_size = size;
+}
+
+int
+VideoDX9::TexSize() const
+{
+ const int max_tex_size = MaxTexSize();
+ return requested_tex_size <= max_tex_size ? requested_tex_size : max_tex_size;
+}
+
int
VideoDX9::MaxTexSize() const
{
diff --git a/StarsEx/VideoDX9.h b/StarsEx/VideoDX9.h
index 9166495..f740a20 100644
--- a/StarsEx/VideoDX9.h
+++ b/StarsEx/VideoDX9.h
@@ -77,6 +77,8 @@ public:
virtual int ZDepth() const { return zdepth; }
virtual DWORD VidMemFree() const;
virtual int D3DLevel() const { return 9; }
+ virtual void RequestTexSize(int size);
+ virtual int TexSize() const;
virtual int MaxTexSize() const;
virtual int MaxTexAspect() const;
virtual int GammaLevel() const { return gamma; }
@@ -133,6 +135,7 @@ private:
int height;
int bpp;
int gamma;
+ int requested_tex_size;
int zdepth;
Color background;
diff --git a/StarsEx/VideoSettings.cpp b/StarsEx/VideoSettings.cpp
index 9ef43b9..6f61c52 100644
--- a/StarsEx/VideoSettings.cpp
+++ b/StarsEx/VideoSettings.cpp
@@ -30,6 +30,7 @@ VideoSettings::VideoSettings()
window_width = 1280;
window_height = 720;
+ tex_size = 2048;
gamma = 128;
is_windowed = false;
use_effects = true;
@@ -48,6 +49,12 @@ VideoSettings::~VideoSettings()
// +--------------------------------------------------------------------+
int
+VideoSettings::GetTexSize() const
+{
+ return tex_size;
+}
+
+int
VideoSettings::GetGammaLevel() const
{
return gamma;
diff --git a/StarsEx/VideoSettings.h b/StarsEx/VideoSettings.h
index b9e74e4..a4b7396 100644
--- a/StarsEx/VideoSettings.h
+++ b/StarsEx/VideoSettings.h
@@ -84,6 +84,7 @@ public:
// accessor methods
+ int GetTexSize() const;
int GetGammaLevel() const;
bool IsWindowed() const;
bool UseEffects() const;
@@ -107,6 +108,7 @@ public:
// properties
+ int tex_size;
int gamma;
bool is_windowed;
bool use_effects;