OXYGENHUB
◆ main openmsx / src / video / VideoSystem.hh
2.9 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#ifndef VIDEOSYSTEM_HH
2
#define VIDEOSYSTEM_HH
3
4
#include "gl_vec.hh"
5
#include "zstring_view.hh"
6
7
#include "components.hh"
8
9
#include <memory>
10
#include <optional>
11
#include <string>
12
13
namespace openmsx {
14
15
class Rasterizer;
16
class VDP;
17
class V9990Rasterizer;
18
class LDRasterizer;
19
class V9990;
20
class LaserdiscPlayer;
21
class OutputSurface;
22
23
/** Video back-end system.
24
  */
25
class VideoSystem
26
{
27
public:
28
	virtual ~VideoSystem() = default;
29
30
	/** Create the rasterizer selected by the current renderer setting.
31
	  * Video systems that use a rasterizer must override this method.
32
	  * @param vdp The VDP whose display will be rendered.
33
	  * @return The rasterizer created.
34
	  */
35
	[[nodiscard]] virtual std::unique_ptr<Rasterizer> createRasterizer(VDP& vdp) = 0;
36
37
	/** Create the V9990 rasterizer selected by the current renderer setting.
38
	  * Video systems that use a rasterizer must override this method.
39
	  * @param vdp The V9990 whose display will be rendered.
40
	  * @return The rasterizer created.
41
	  */
42
	[[nodiscard]] virtual std::unique_ptr<V9990Rasterizer> createV9990Rasterizer(
43
		V9990& vdp) = 0;
44
45
#if COMPONENT_LASERDISC
46
	[[nodiscard]] virtual std::unique_ptr<LDRasterizer> createLDRasterizer(
47
		LaserdiscPlayer &ld) = 0;
48
#endif
49
50
	/** Finish pending drawing operations and make them visible to the user.
51
	  */
52
	virtual void flush() = 0;
53
54
	/** Take a screenshot.
55
	  * The default implementation throws an exception.
56
	  * @param filename Name of the file to save the screenshot to.
57
	  * @param withOsd Should OSD elements be included in the screenshot.
58
	  * @throws MSXException If taking the screen shot fails.
59
	  */
60
	virtual void takeScreenShot(const std::string& filename, bool withOsd);
61
62
	/** Called when the window title string has changed.
63
	  */
64
	virtual void updateWindowTitle();
65
66
	/** Returns the current mouse pointer coordinates in the main window.
67
	  * Returns std::nullopt when the main window does not have focus.
68
	  */
69
	[[nodiscard]] virtual std::optional<gl::ivec2> getMouseCoord() = 0;
70
71
	/** Returns the size of a single MSX pixel as it is currently drawn on
72
	  * screen, expressed in the same units as the mouse coordinates (SDL
73
	  * window coordinates, which on high-DPI displays are not the same as
74
	  * physical pixels).
75
	  * Returns std::nullopt when there's no window to draw on.
76
	  */
77
	[[nodiscard]] virtual std::optional<gl::vec2> getMsxPixelSize() = 0;
78
79
	/** TODO */
80
	[[nodiscard]] virtual OutputSurface* getOutputSurface() = 0;
81
	virtual void showCursor(bool show) = 0;
82
	[[nodiscard]] virtual bool getCursorEnabled() = 0;
83
	[[nodiscard]] virtual std::string getClipboardText() = 0;
84
	virtual void setClipboardText(zstring_view text) = 0;
85
86
	[[nodiscard]] virtual std::optional<gl::ivec2> getWindowPosition() = 0;
87
	virtual void setWindowPosition(gl::ivec2 pos) = 0;
88
89
	/** Requests a repaint of the output surface. An implementation might
90
	 *  start a repaint directly, or trigger a queued rendering. */
91
	virtual void repaint() = 0;
92
93
protected:
94
	VideoSystem() = default;
95
};
96
97
} // namespace openmsx
98
99
#endif