ScummVM API documentation
sdl.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef PLATFORM_SDL_H
23 #define PLATFORM_SDL_H
24 
25 #include "backends/platform/sdl/sdl-sys.h"
26 
27 #include "backends/modular-backend.h"
28 #include "backends/mixer/sdl/sdl-mixer.h"
29 #include "backends/events/sdl/sdl-events.h"
30 #include "backends/log/log.h"
31 #include "backends/platform/sdl/sdl-window.h"
32 
33 #include "common/array.h"
34 
35 #ifdef USE_DISCORD
36 class DiscordPresence;
37 #endif
38 
43 public:
44  OSystem_SDL();
45  virtual ~OSystem_SDL();
46 
52  void init() override;
53 
54  bool hasFeature(Feature f) override;
55 
56  // Override functions from ModularBackend and OSystem
57  void initBackend() override;
58  void engineInit() override;
59  void engineDone() override;
60  void quit() override;
61  void fatalError() override;
64 
65  // Logging
66  void logMessage(LogMessageType::Type type, const char *message) override;
67 
68  Common::String getSystemLanguage() const override;
69 
70 #if SDL_VERSION_ATLEAST(2, 0, 0)
71  // Clipboard
72  bool hasTextInClipboard() override;
74  bool setTextInClipboard(const Common::U32String &text) override;
75 
76  void messageBox(LogMessageType::Type type, const char *message) override;
77 #endif
78 
79 #if SDL_VERSION_ATLEAST(2, 0, 14)
80  bool openUrl(const Common::String &url) override;
81 #endif
82 
83  void setWindowCaption(const Common::U32String &caption) override;
84  void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
86  uint32 getMillis(bool skipRecord = false) override;
87  void delayMillis(uint msecs) override;
88  void getTimeAndDate(TimeDate &td, bool skipRecord = false) const override;
89  MixerManager *getMixerManager() override;
92  uint32 getDoubleClickTime() const override;
93 
94  // Default paths
95  virtual Common::Path getDefaultIconsPath();
96  virtual Common::Path getDefaultDLCsPath();
97  virtual Common::Path getScreenshotsPath();
98 
99 #if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
101  OpenGL::ContextType getOpenGLType() const override { return _oglType; }
102 #endif
103 #if defined(USE_OPENGL) && defined(USE_GLAD)
104  void *getOpenGLProcAddress(const char *name) const override;
105 #endif
106 
107 protected:
108  bool _inited;
109  bool _initedSDL;
110 #ifdef USE_SDL_NET
111  bool _initedSDLnet;
112 #endif
113 
114 #ifdef USE_DISCORD
115  DiscordPresence *_presence;
116 #endif
117 
127 
132  Common::EventSource *_eventSourceWrapper;
133 
138 
139  SdlGraphicsManager::State _gfxManagerState;
140 
141 #if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
142  // Graphics capabilities
143  void detectOpenGLFeaturesSupport();
144  void detectAntiAliasingSupport();
145 
146  OpenGL::ContextType _oglType;
147  bool _supportsFrameBuffer;
148  bool _supportsShaders;
149  Common::Array<uint> _antiAliasLevels;
150 #endif
151 
155  virtual void initSDL();
156 
161 
162  // Logging
163  virtual Common::WriteStream *createLogFile();
164  Backends::Log::Log *_logger;
165 
166 #ifdef USE_OPENGL
167  typedef Common::Array<GraphicsMode> GraphicsModeArray;
168  GraphicsModeArray _graphicsModes;
169  Common::Array<int> _graphicsModeIds;
170  int _graphicsMode;
171  int _firstGLMode;
172  int _defaultSDLMode;
173  int _defaultGLMode;
174 
178  void setupGraphicsModes();
179 
183  void clearGraphicsModes();
184 
185  enum GraphicsManagerType { GraphicsManagerSDL, GraphicsManagerOpenGL };
186  virtual GraphicsManagerType getDefaultGraphicsManager() const { return GraphicsManagerSDL; }
187  const OSystem::GraphicsMode *getSupportedGraphicsModes() const override;
188  int getDefaultGraphicsMode() const override;
189  bool setGraphicsMode(int mode, uint flags) override;
190  int getGraphicsMode() const override;
191 #endif
192 
193  virtual uint32 getOSDoubleClickTime() const { return 0; }
194  virtual const char * const *buildHelpDialogData() override;
195 };
196 
197 #endif
bool setGraphicsMode(int mode, uint flags=kGfxModeNoFlags) override
Definition: modular-backend.h:147
Definition: sdl.h:42
void initBackend() override
void getTimeAndDate(TimeDate &td, bool skipRecord=false) const override
Definition: modular-backend.h:48
virtual void messageBox(LogMessageType::Type type, const char *message)
Definition: system.h:1897
Definition: system.h:105
Definition: str.h:59
SdlWindow * _window
Definition: sdl.h:137
Definition: sdl-events.h:40
Definition: stream.h:77
Definition: log.h:41
virtual void initSDL()
virtual Common::Array< uint > getSupportedAntiAliasingLevels() const
Definition: system.h:885
Definition: array.h:52
Definition: system.h:739
void addSysArchivesToSearchSet(Common::SearchSet &s, int priority=0) override
void engineDone() override
Common::SaveFileManager * getSavefileManager() override
Feature
Definition: system.h:417
Common::Path _logFilePath
Definition: sdl.h:126
uint32 getMillis(bool skipRecord=false) override
uint32 getDoubleClickTime() const override
Definition: path.h:52
void delayMillis(uint msecs) override
virtual const char *const * buildHelpDialogData() override
const GraphicsMode * getSupportedGraphicsModes() const override
void fatalError() override
Type
Definition: system.h:121
int getDefaultGraphicsMode() const override
Definition: sdl-graphics.h:107
int getGraphicsMode() const override
virtual bool openUrl(const Common::String &url)
Definition: system.h:1971
virtual bool hasTextInClipboard()
Definition: system.h:1935
virtual bool setTextInClipboard(const Common::U32String &text)
Definition: system.h:1957
Definition: timer.h:40
Definition: ustr.h:57
virtual OpenGL::ContextType getOpenGLType() const
Definition: system.h:899
Definition: archive.h:312
Definition: hardware-input.h:199
Common::KeymapArray getGlobalKeymaps() override
Common::MutexInternal * createMutex() override
void init() override
void setWindowCaption(const Common::U32String &caption) override
Definition: mixer.h:31
Common::TimerManager * getTimerManager() override
SdlEventSource * _eventSource
Definition: sdl.h:131
void logMessage(LogMessageType::Type type, const char *message) override
void engineInit() override
Definition: savefile.h:142
virtual Common::U32String getTextFromClipboard()
Definition: system.h:1946
bool hasFeature(Feature f) override
Definition: events.h:258
Definition: mutex.h:40
Definition: sdl-window.h:30
virtual AudioCDManager * createAudioCDManager()
void quit() override
Definition: audiocd.h:33
Common::HardwareInputSet * getHardwareInputSet() override
Common::String getSystemLanguage() const override