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 bool signalEvent(const Event& event) override;
81
82 // RTSchedulable
83 void executeRT() override;
84
85private:
86 void updateCursor();
87 void createSurface(gl::ivec2 size, unsigned flags);
88 void setViewPort(gl::ivec2 logicalSize, bool fullScreen);
89
90private:
91 Display& display;
92 EventDistributor& eventDistributor;
93 InputEventGenerator& inputEventGenerator;
94 CliComm& cliComm;
95 VideoSystem& videoSystem;
96
97 struct VSyncObserver : openmsx::Observer<Setting> {
98 void update(const Setting& setting) noexcept override;
99 } vSyncObserver;
100
101 [[no_unique_address]] SDLSubSystemInitializer<SDL_INIT_VIDEO> videoSubSystem;
102 SDLWindowPtr window;
103 SDL_GLContext glContext;
104
105 bool grab = false;
106 bool guiActive = false;
107
108 static int windowPosX;
109 static int windowPosY;
110};
111
112} // namespace openmsx
113
114#endif
BaseSetting * setting
std::unique_ptr< SDL_Window, SDLDestroyWindow > SDLWindowPtr
Represents the output window/screen of openMSX.
Definition Display.hh:31
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)
bool signalEvent(const Event &event) override
This method gets called when an event you are subscribed to occurs.
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
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:445