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 [[nodiscard]] gl::ivec2 getWindowSize() const;
87 void updateCursor();
88 void createSurface(int width, int height, unsigned flags);
89 void setViewPort(gl::ivec2 logicalSize, bool fullScreen);
90
91private:
92 Display& display;
93 EventDistributor& eventDistributor;
94 InputEventGenerator& inputEventGenerator;
95 CliComm& cliComm;
96 VideoSystem& videoSystem;
97
98 struct VSyncObserver : openmsx::Observer<Setting> {
99 void update(const Setting& setting) noexcept override;
100 } vSyncObserver;
101
102 [[no_unique_address]] SDLSubSystemInitializer<SDL_INIT_VIDEO> videoSubSystem;
103 SDLWindowPtr window;
104 SDL_GLContext glContext;
105
106 bool grab = false;
107 bool guiActive = false;
108
109 static int windowPosX;
110 static int windowPosY;
111};
112
113} // namespace openmsx
114
115#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)
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