openMSX
VisibleSurface.hh
Go to the documentation of this file.
1 #ifndef VISIBLESURFACE_HH
2 #define VISIBLESURFACE_HH
3 
4 #include "OutputSurface.hh"
5 #include "Observer.hh"
6 #include "EventListener.hh"
7 #include "RTSchedulable.hh"
8 #include "SDLSurfacePtr.hh"
9 #include <memory>
10 
11 namespace openmsx {
12 
13 class Layer;
14 class Reactor;
15 class CommandConsole;
16 class EventDistributor;
17 class InputEventGenerator;
18 class Setting;
19 class Display;
20 class OSDGUI;
21 class CliComm;
22 
29  private Observer<Setting>, private RTSchedulable
30 {
31 public:
32  ~VisibleSurface() override;
33  void updateWindowTitle();
34  bool setFullScreen(bool fullscreen);
35 
40  virtual void finish() = 0;
41 
42  virtual std::unique_ptr<Layer> createSnowLayer() = 0;
43  virtual std::unique_ptr<Layer> createConsoleLayer(
44  Reactor& reactor, CommandConsole& console) = 0;
45  virtual std::unique_ptr<Layer> createOSDGUILayer(OSDGUI& gui) = 0;
46 
51  virtual std::unique_ptr<OutputSurface> createOffScreenSurface() = 0;
52 
53  Display& getDisplay() const { return display; }
54 
55 protected:
56  VisibleSurface(Display& display,
57  RTScheduler& rtScheduler,
58  EventDistributor& eventDistributor,
59  InputEventGenerator& inputEventGenerator,
60  CliComm& cliComm);
61  void createSurface(int width, int height, unsigned flags);
62 
68 
69 private:
70  void updateCursor();
71 
72  // Observer
73  void update(const Setting& setting) override;
74  // EventListener
75  int signalEvent(const std::shared_ptr<const Event>& event) override;
76  // RTSchedulable
77  void executeRT() override;
78 
79  Display& display;
80  EventDistributor& eventDistributor;
81  InputEventGenerator& inputEventGenerator;
82  CliComm& cliComm;
83 };
84 
85 } // namespace openmsx
86 
87 #endif
Contains the main loop of openMSX.
Definition: Reactor.hh:64
Represents the output window/screen of openMSX.
Definition: Display.hh:31
virtual std::unique_ptr< Layer > createOSDGUILayer(OSDGUI &gui)=0
std::unique_ptr< SDL_Renderer, SDLDestroyRenderer > SDLRendererPtr
virtual void finish()=0
When a complete frame is finished, call this method.
A frame buffer where pixels can be written to.
Wrapper around a SDL_Surface.
Display & getDisplay() const
virtual std::unique_ptr< OutputSurface > createOffScreenSurface()=0
Create an off-screen OutputSurface which has similar properties as this VisibleSurface.
SDLSubSystemInitializer< SDL_INIT_VIDEO > videoSubSystem
An OutputSurface which is visible to the user, such as a window or a full screen display.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
std::unique_ptr< SDL_Window, SDLDestroyWindow > SDLWindowPtr
bool setFullScreen(bool fullscreen)
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9
void createSurface(int width, int height, unsigned flags)
std::unique_ptr< SDL_Texture, SDLDestroyTexture > SDLTexturePtr
VisibleSurface(Display &display, RTScheduler &rtScheduler, EventDistributor &eventDistributor, InputEventGenerator &inputEventGenerator, CliComm &cliComm)
virtual std::unique_ptr< Layer > createConsoleLayer(Reactor &reactor, CommandConsole &console)=0
virtual std::unique_ptr< Layer > createSnowLayer()=0