s25client icon indicating copy to clipboard operation
s25client copied to clipboard

Status of WinAPI backend and querying capabilities

Open falbrechtskirchinger opened this issue 2 years ago • 2 comments

What is the official status of the WinAPI video backend?

I've mostly ignored it in my PRs and the feature set continues to diverge. When new features are exposed in the options screen, users should be informed if selected options are ineffective or not able to select them in the first place. Is it worth adding a GetCapabilities() function to IVideoDriver?

It could look something like this:

// Bitset details to be figured out separately
enum class DisplayMode : unsigned {
	None,
	Window = …,
	NonResizableWindow = …,
	Fullscreen = ...,
	WindowedFullscreen = …
};

struct VideoDriverCapabilities {
	DisplayMode displayMode{};
	bool guiScale = false;
	// someday maybe?
	// bool copy;
	// bool paste;
};

class IVideoDriver {
	virtual VideoDriverCapabilities GetCapabilities() const = 0;
};

class VideoSDL2 {
	VideoDriverCapabilities GetCapabilities() const override {
		VideoDriverCapabilities cap{};
		cap.displayMode = DisplayMode::Window | DisplayMode::NonResizableWindow | DisplayMode::Fullscreen | DisplayMode::WindowedFullscreen;
		cap.guiScale = true;
		return cap;
	}
};

class VideoWinAPI {
	VideoDriverCapabilities GetCapabilities() const override {
		VideoDriverCapabilities cap{};
		cap.displayMode = DisplayMode::Window | DisplayMode::Fullscreen;
		return cap;
	}
};

Further, to reduce duplication between dskOptions and iwSettings:

struct DisplayModeItem {
	std::string text;
	DisplayMode value;
};

std::vector<DisplayModeItem> displayModeItemsFromCapabilities(const VideoDriverCapabilities& cap);

The DisplayModeItems would then be used to populate a ComboBox and map the selection index to a DisplayMode value.

falbrechtskirchinger avatar Jul 26 '23 15:07 falbrechtskirchinger

What is the official status of the WinAPI video backend?

Should be supported, since for a some people its working better than SDL

Flow86 avatar Jul 28 '23 20:07 Flow86

What is the official status of the WinAPI video backend?

Should be supported, since for a some people its working better than SDL

Ok, thanks! I've already looked into adding non-resizable windows, which is trivial. That leaves windowed fullscreen and GUI scaling. Support for GUI scaling can be detected without the proposed API and is already implemented in #1594. Maybe I'll just implement windowed fullscreen by copying it from Chromium (BSD-3-licensed, so that'll work).

We won't need a capability API for the time being.

falbrechtskirchinger avatar Jul 29 '23 05:07 falbrechtskirchinger