openMSX
VisibleSurface.hh
Go to the documentation of this file.
1#ifndef VISIBLESURFACE_HH
2#define VISIBLESURFACE_HH
3
4#include "EventListener.hh"
5#include "Observer.hh"
6#include "OutputSurface.hh"
7#include "RTSchedulable.hh"
8#include "SDLSurfacePtr.hh"
9#include <memory>
10
11namespace openmsx {
12
13class CliComm;
14class CommandConsole;
15class Display;
16class EventDistributor;
17class ImGuiManager;
18class InputEventGenerator;
19class Layer;
20class OSDGUI;
21class Reactor;
22class Setting;
23class VideoSystem;
24
28class VisibleSurface final : public OutputSurface, public EventListener
29 , private Observer<Setting>, private RTSchedulable
30{
31public:
32 VisibleSurface(Display& display,
33 RTScheduler& rtScheduler,
34 EventDistributor& eventDistributor,
35 InputEventGenerator& inputEventGenerator,
36 CliComm& cliComm,
37 VideoSystem& videoSystem);
38 ~VisibleSurface() override;
39
40 [[nodiscard]] CliComm& getCliComm() const { return cliComm; }
41 [[nodiscard]] Display& getDisplay() const { return display; }
42
43 static void saveScreenshotGL(const OutputSurface& output,
44 const std::string& filename);
45
46 void updateWindowTitle();
47 bool setFullScreen(bool fullscreen);
48 void resize();
49
54 void finish();
55
56 [[nodiscard]] std::unique_ptr<Layer> createSnowLayer();
57 [[nodiscard]] std::unique_ptr<Layer> createOSDGUILayer(OSDGUI& gui);
58 [[nodiscard]] std::unique_ptr<Layer> createImGUILayer(ImGuiManager& manager);
59
64 [[nodiscard]] std::unique_ptr<OutputSurface> createOffScreenSurface();
65
66 void fullScreenUpdated(bool fullScreen);
67
70 std::optional<gl::ivec2> getWindowPosition() const;
72
73 // OutputSurface
74 void saveScreenshot(const std::string& filename) override;
75
76 // Observer
77 void update(const Setting& setting) noexcept override;
78
79 // EventListener
80 int signalEvent(const Event& event) override;
81
82 // RTSchedulable
83 void executeRT() override;
84
85 bool guiActive = false;
86
87private:
88 [[nodiscard]] gl::ivec2 getWindowSize() const;
89 void updateCursor();
90 void createSurface(int width, int height, unsigned flags);
91 void setViewPort(gl::ivec2 logicalSize, bool fullScreen);
92
93private:
94 Display& display;
95 EventDistributor& eventDistributor;
96 InputEventGenerator& inputEventGenerator;
97 CliComm& cliComm;
98 VideoSystem& videoSystem;
99
100 struct VSyncObserver : openmsx::Observer<Setting> {
101 void update(const Setting& setting) noexcept override;
102 } vSyncObserver;
103
104 [[no_unique_address]] SDLSubSystemInitializer<SDL_INIT_VIDEO> videoSubSystem;
105 SDLWindowPtr window;
106 SDL_GLContext glContext;
107
108 bool grab = false;
109
110 static int windowPosX;
111 static int windowPosY;
112};
113
114} // namespace openmsx
115
116#endif
BaseSetting * setting
std::unique_ptr< SDL_Window, SDLDestroyWindow > SDLWindowPtr
Represents the output window/screen of openMSX.
Definition Display.hh:32
Generic Gang-of-Four Observer class, templatized edition.
Definition Observer.hh:10
A frame buffer where pixels can be written to.
Video back-end system.
An OutputSurface which is visible to the user, such as a window or a full screen display.
void finish()
When a complete frame is finished, call this method.
std::unique_ptr< Layer > createImGUILayer(ImGuiManager &manager)
Display & getDisplay() const
static void saveScreenshotGL(const OutputSurface &output, const std::string &filename)
void update(const Setting &setting) noexcept override
void setWindowPosition(gl::ivec2 pos)
void fullScreenUpdated(bool fullScreen)
std::unique_ptr< OutputSurface > createOffScreenSurface()
Create an off-screen OutputSurface which has similar properties as this VisibleSurface.
std::unique_ptr< Layer > createSnowLayer()
void saveScreenshot(const std::string &filename) override
Save the content of this OutputSurface to a PNG file.
std::optional< gl::ivec2 > getWindowPosition() const
Returns x,y coordinates of top-left window corner, or returns a nullopt when in fullscreen mode.
bool setFullScreen(bool fullscreen)
CliComm & getCliComm() const
int signalEvent(const Event &event) override
This method gets called when an event you are subscribed to occurs.
std::unique_ptr< Layer > createOSDGUILayer(OSDGUI &gui)
This file implemented 3 utility functions:
Definition Autofire.cc:11
std::variant< KeyUpEvent, KeyDownEvent, MouseMotionEvent, MouseButtonUpEvent, MouseButtonDownEvent, MouseWheelEvent, JoystickAxisMotionEvent, JoystickHatEvent, JoystickButtonUpEvent, JoystickButtonDownEvent, OsdControlReleaseEvent, OsdControlPressEvent, WindowEvent, TextEvent, FileDropEvent, QuitEvent, FinishFrameEvent, CliCommandEvent, GroupEvent, BootEvent, FrameDrawnEvent, BreakEvent, SwitchRendererEvent, TakeReverseSnapshotEvent, AfterTimedEvent, MachineLoadedEvent, MachineActivatedEvent, MachineDeactivatedEvent, MidiInReaderEvent, MidiInWindowsEvent, MidiInCoreMidiEvent, MidiInCoreMidiVirtualEvent, MidiInALSAEvent, Rs232TesterEvent, Rs232NetEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
Definition Event.hh:444