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_OPENGL
36#define USE_MULTIPLE_RENDERERS
37#endif
38
39#ifdef USE_DISCORD
40class DiscordPresence;
41#endif
42
47public:
49 virtual ~OSystem_SDL();
50
56 void init() override;
57
58 bool hasFeature(Feature f) override;
59 void setFeatureState(Feature f, bool enable) override;
60 bool getFeatureState(Feature f) override;
61
62 // Override functions from ModularBackend and OSystem
63 void initBackend() override;
64 void engineInit() override;
65 void engineDone() override;
66 void quit() override;
67 void fatalError() override;
70
71 // Logging
72 void logMessage(LogMessageType::Type type, const char *message) override;
73
75
76#if SDL_VERSION_ATLEAST(2, 0, 0)
77 // Clipboard
78 bool hasTextInClipboard() override;
80 bool setTextInClipboard(const Common::U32String &text) override;
81
82 void messageBox(LogMessageType::Type type, const char *message) override;
83#endif
84
85#if SDL_VERSION_ATLEAST(2, 0, 14)
86 bool openUrl(const Common::String &url) override;
87#endif
88
89 void setWindowCaption(const Common::U32String &caption) override;
90 void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
92 uint32 getMillis(bool skipRecord = false) override;
93 void delayMillis(uint msecs) override;
94 void getTimeAndDate(TimeDate &td, bool skipRecord = false) const override;
95 MixerManager *getMixerManager() override;
98 uint32 getDoubleClickTime() const override;
99
100 // Default paths
101 virtual Common::Path getDefaultIconsPath();
102 virtual Common::Path getDefaultDLCsPath();
103 virtual Common::Path getScreenshotsPath();
104
105#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
107 OpenGL::ContextType getOpenGLType() const override { return _oglType; }
108#endif
109#if defined(USE_OPENGL) && defined(USE_GLAD)
110 void *getOpenGLProcAddress(const char *name) const override;
111#endif
112
113protected:
114 bool _inited;
115 bool _initedSDL;
116#ifdef USE_SDL_NET
117 bool _initedSDLnet;
118#endif
119
120#ifdef USE_DISCORD
121 DiscordPresence *_presence;
122#endif
123
133
138 Common::EventSource *_eventSourceWrapper;
139
144
145 SdlGraphicsManager::State _gfxManagerState;
146
147#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
148 // Graphics capabilities
149 void detectOpenGLFeaturesSupport();
150 void detectAntiAliasingSupport();
151
152 OpenGL::ContextType _oglType;
153 bool _supportsShaders;
154 Common::Array<uint> _antiAliasLevels;
155#endif
156
160 virtual void initSDL();
161
166
167 // Logging
168 virtual Common::WriteStream *createLogFile();
169 Backends::Log::Log *_logger;
170
171#ifdef USE_MULTIPLE_RENDERERS
172 enum GraphicsManagerType {
173 GraphicsManagerSurfaceSDL,
174#ifdef USE_OPENGL
175 GraphicsManagerOpenGL,
176#endif
177 GraphicsManagerCount
178 };
179
180 typedef Common::Array<GraphicsMode> GraphicsModeArray;
181 GraphicsModeArray _graphicsModes;
182 Common::Array<int> _graphicsModeIds;
183 int _graphicsMode;
184 int _firstMode[GraphicsManagerCount];
185 int _lastMode[GraphicsManagerCount];
186 int _defaultMode[GraphicsManagerCount];
187 int _supports3D[GraphicsManagerCount];
188
192 void setupGraphicsModes();
193
197 void clearGraphicsModes();
198
199 virtual GraphicsManagerType getDefaultGraphicsManager() const;
200 SdlGraphicsManager *createGraphicsManager(SdlEventSource *sdlEventSource, SdlWindow *window, GraphicsManagerType type);
201 const OSystem::GraphicsMode *getSupportedGraphicsModes() const override;
202 int getDefaultGraphicsMode() const override;
203 bool setGraphicsMode(int mode, uint flags) override;
204 int getGraphicsMode() const override;
205#endif
206
207 virtual uint32 getOSDoubleClickTime() const { return 0; }
208 const char * const *buildHelpDialogData() override;
209};
210
211#endif
Definition: audiocd.h:33
Definition: log.h:41
Definition: events.h:278
Definition: hardware-input.h:199
Definition: mutex.h:40
Definition: path.h:52
Definition: savefile.h:142
Definition: archive.h:330
Definition: str.h:59
Definition: timer.h:40
Definition: ustr.h:57
Definition: stream.h:77
Definition: mixer.h:31
Definition: modular-backend.h:48
int getDefaultGraphicsMode() const override
bool setGraphicsMode(int mode, uint flags=kGfxModeNoFlags) override
int getGraphicsMode() const override
const GraphicsMode * getSupportedGraphicsModes() const override
Definition: modular-backend.h:152
Definition: sdl.h:46
Common::Path _logFilePath
Definition: sdl.h:132
void addSysArchivesToSearchSet(Common::SearchSet &s, int priority=0) override
uint32 getMillis(bool skipRecord=false) override
Common::KeymapArray getGlobalKeymaps() override
Common::SaveFileManager * getSavefileManager() override
void quit() override
void initBackend() override
const char *const * buildHelpDialogData() override
Common::TimerManager * getTimerManager() override
bool hasFeature(Feature f) override
Common::String getSystemLanguage() const override
void engineInit() override
void engineDone() override
virtual AudioCDManager * createAudioCDManager()
Common::HardwareInputSet * getHardwareInputSet() override
void delayMillis(uint msecs) override
Common::MutexInternal * createMutex() override
void fatalError() override
void logMessage(LogMessageType::Type type, const char *message) override
uint32 getDoubleClickTime() const override
void getTimeAndDate(TimeDate &td, bool skipRecord=false) const override
bool getFeatureState(Feature f) override
SdlEventSource * _eventSource
Definition: sdl.h:137
void init() override
virtual void initSDL()
void setWindowCaption(const Common::U32String &caption) override
SdlWindow * _window
Definition: sdl.h:143
void setFeatureState(Feature f, bool enable) override
Definition: sdl-events.h:40
Definition: sdl-graphics.h:38
Definition: sdl-window.h:30
Feature
Definition: system.h:415
virtual OpenGL::ContextType getOpenGLType() const
Definition: system.h:901
virtual Common::Array< uint > getSupportedAntiAliasingLevels() const
Definition: system.h:887
virtual void messageBox(LogMessageType::Type type, const char *message)
Definition: system.h:1965
virtual Common::U32String getTextFromClipboard()
Definition: system.h:2014
virtual bool openUrl(const Common::String &url)
Definition: system.h:2039
virtual bool hasTextInClipboard()
Definition: system.h:2003
virtual bool setTextInClipboard(const Common::U32String &text)
Definition: system.h:2025
Type
Definition: log.h:33
Definition: system.h:741
Definition: sdl-graphics.h:109
Definition: system.h:111