summaryrefslogtreecommitdiffhomepage
path: root/StarsEx/VideoSettings.cpp
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-01 21:23:39 +0200
committerAki <please@ignore.pl>2022-04-01 21:23:39 +0200
commit3c487c5cd69c53d6fea948643c0a76df03516605 (patch)
tree72730c7b8b26a5ef8fc9a987ec4c16129efd5aac /StarsEx/VideoSettings.cpp
parent8f353abd0bfe18baddd8a8250ab7c4f2d1c83a6e (diff)
downloadstarshatter-3c487c5cd69c53d6fea948643c0a76df03516605.zip
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.gz
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.bz2
Moved Stars45 to StarsEx
Diffstat (limited to 'StarsEx/VideoSettings.cpp')
-rw-r--r--StarsEx/VideoSettings.cpp273
1 files changed, 273 insertions, 0 deletions
diff --git a/StarsEx/VideoSettings.cpp b/StarsEx/VideoSettings.cpp
new file mode 100644
index 0000000..9ef43b9
--- /dev/null
+++ b/StarsEx/VideoSettings.cpp
@@ -0,0 +1,273 @@
+/* Starshatter: The Open Source Project
+ Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors
+ Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
+ Copyright (c) 1997-2006, Destroyer Studios LLC.
+
+ AUTHOR: John DiCamillo
+
+
+ OVERVIEW
+ ========
+ Video Settings class implementation
+*/
+
+#include "VideoSettings.h"
+
+// +--------------------------------------------------------------------+
+
+VideoSettings::VideoSettings()
+{
+ fullscreen_mode.width = 1024;
+ fullscreen_mode.height = 768;
+ fullscreen_mode.refresh = 75;
+ fullscreen_mode.format = VideoMode::FMT_X8R8G8B8;
+
+ windowed_mode.width = 1280;
+ windowed_mode.height = 720;
+ windowed_mode.refresh = 0;
+ windowed_mode.format = VideoMode::FMT_NONE;
+
+ window_width = 1280;
+ window_height = 720;
+
+ gamma = 128;
+ is_windowed = false;
+ use_effects = true;
+ shadows = true;
+ bumpmaps = true;
+ specmaps = true;
+ max_detail = 4;
+ enable_vs = true;
+ enable_ps = true;
+ depth_bias = 0;
+}
+
+VideoSettings::~VideoSettings()
+{ }
+
+// +--------------------------------------------------------------------+
+
+int
+VideoSettings::GetGammaLevel() const
+{
+ return gamma;
+}
+
+bool
+VideoSettings::IsWindowed() const
+{
+ return is_windowed;
+}
+
+bool
+VideoSettings::UseEffects() const
+{
+ return use_effects;
+}
+
+int
+VideoSettings::GetWidth() const
+{
+ if (is_windowed)
+ return window_width;
+
+ return fullscreen_mode.width;
+}
+
+int
+VideoSettings::GetHeight() const
+{
+ if (is_windowed)
+ return window_height;
+
+ return fullscreen_mode.height;
+}
+
+int
+VideoSettings::GetDepth() const
+{
+ int fmt = 0;
+ int bpp = 0;
+
+ if (is_windowed)
+ fmt = windowed_mode.format;
+ else
+ fmt = fullscreen_mode.format;
+
+ switch (fmt) {
+ default:
+ case VideoMode::FMT_NONE: bpp = 0; break;
+ case VideoMode::FMT_R5G5B5: bpp = 15; break;
+ case VideoMode::FMT_R5G6B5: bpp = 16; break;
+ case VideoMode::FMT_R8G8B8: bpp = 24; break;
+ case VideoMode::FMT_X8R8G8B8: bpp = 32; break;
+ }
+
+ return bpp;
+}
+
+int
+VideoSettings::GetPixSize() const
+{
+ int fmt = 0;
+ int pix = 0;
+
+ if (is_windowed)
+ fmt = windowed_mode.format;
+ else
+ fmt = fullscreen_mode.format;
+
+ switch (fmt) {
+ default:
+ case VideoMode::FMT_NONE: pix = 0; break;
+ case VideoMode::FMT_R5G5B5: pix = 2; break;
+ case VideoMode::FMT_R5G6B5: pix = 2; break;
+ case VideoMode::FMT_R8G8B8: pix = 3; break;
+ case VideoMode::FMT_X8R8G8B8: pix = 4; break;
+ }
+
+ return pix;
+}
+
+int
+VideoSettings::GetRefreshRate() const
+{
+ if (is_windowed)
+ return windowed_mode.refresh;
+
+ return fullscreen_mode.refresh;
+}
+
+// +--------------------------------------------------------------------+
+
+const char*
+VideoSettings::GetModeDescription() const
+{
+ if (is_windowed)
+ return windowed_mode.GetDescription();
+
+ return fullscreen_mode.GetDescription();
+}
+
+// +--------------------------------------------------------------------+
+
+int
+VideoSettings::GetVertexProcessing() const
+{
+ if (is_windowed)
+ return windowed_device.vertex_processing;
+
+ return fullscreen_device.vertex_processing;
+}
+
+int
+VideoSettings::GetDepthBufferBits() const
+{
+ if (is_windowed)
+ return windowed_device.depth_buffer_bits;
+
+ return fullscreen_device.depth_buffer_bits;
+}
+
+int
+VideoSettings::GetAdapterIndex() const
+{
+ if (is_windowed)
+ return windowed_device.adapter_index;
+
+ return fullscreen_device.adapter_index;
+}
+
+int
+VideoSettings::GetDeviceIndex() const
+{
+ if (is_windowed)
+ return windowed_device.device_index;
+
+ return fullscreen_device.device_index;
+}
+
+DWORD
+VideoSettings::GetDeviceType() const
+{
+ if (is_windowed)
+ return windowed_device.device_type;
+
+ return fullscreen_device.device_type;
+}
+
+DWORD
+VideoSettings::GetDepthStencilFormat() const
+{
+ if (is_windowed)
+ return windowed_device.depth_stencil_format;
+
+ return fullscreen_device.depth_stencil_format;
+}
+
+DWORD
+VideoSettings::GetBackBufferFormat() const
+{
+ if (is_windowed)
+ return windowed_device.back_buffer_format;
+
+ return fullscreen_device.back_buffer_format;
+}
+
+const char*
+VideoSettings::GetAdapterDesc() const
+{
+ if (is_windowed)
+ return windowed_device.adapter_desc;
+
+ return fullscreen_device.adapter_desc;
+}
+
+const char*
+VideoSettings::GetDeviceDesc() const
+{
+ if (is_windowed)
+ return windowed_device.device_desc;
+
+ return fullscreen_device.device_desc;
+}
+
+
+// +--------------------------------------------------------------------+
+// +--------------------------------------------------------------------+
+// +--------------------------------------------------------------------+
+
+const char*
+VideoMode::GetDescription() const
+{
+ static char desc[32];
+
+ int bpp = 0;
+ switch (format) {
+ default:
+ case VideoMode::FMT_NONE: bpp = 0; break;
+ case VideoMode::FMT_R5G5B5: bpp = 15; break;
+ case VideoMode::FMT_R5G6B5: bpp = 16; break;
+ case VideoMode::FMT_R8G8B8: bpp = 24; break;
+ case VideoMode::FMT_X8R8G8B8: bpp = 32; break;
+ }
+
+ sprintf_s(desc, "%d x %d x %d", width, height, bpp);
+ return desc;
+}
+
+// +--------------------------------------------------------------------+
+// +--------------------------------------------------------------------+
+// +--------------------------------------------------------------------+
+
+VideoDeviceInfo::VideoDeviceInfo()
+{
+ ZeroMemory(this, sizeof(VideoDeviceInfo));
+
+ vertex_processing = VideoSettings::VTX_HARDWARE;
+ depth_buffer_bits = 32;
+}
+
+VideoDeviceInfo::~VideoDeviceInfo()
+{
+}