ScummVM API documentation
openglsdl-graphics.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 BACKENDS_GRAPHICS_OPENGLSDL_OPENGLSDL_GRAPHICS_H
23 #define BACKENDS_GRAPHICS_OPENGLSDL_OPENGLSDL_GRAPHICS_H
24 
25 #include "backends/graphics/opengl/opengl-graphics.h"
26 #include "backends/graphics/sdl/sdl-graphics.h"
27 #include "backends/platform/sdl/sdl-sys.h"
28 
29 #include "common/array.h"
30 #include "common/events.h"
31 
33 public:
34  OpenGLSdlGraphicsManager(SdlEventSource *eventSource, SdlWindow *window);
35  virtual ~OpenGLSdlGraphicsManager();
36 
37  bool hasFeature(OSystem::Feature f) const override;
38  void setFeatureState(OSystem::Feature f, bool enable) override;
39  bool getFeatureState(OSystem::Feature f) const override;
40 
41  void initSize(uint w, uint h, const Graphics::PixelFormat *format) override;
42  void updateScreen() override;
43 
44  float getHiDPIScreenFactor() const override;
45 
46  // EventObserver API
47  bool notifyEvent(const Common::Event &event) override;
48 
49  // SdlGraphicsManager API
50  void notifyVideoExpose() override;
51  void notifyResize(const int width, const int height) override;
52 
53 #if defined(USE_IMGUI) && SDL_VERSION_ATLEAST(2, 0, 0)
54  void *getImGuiTexture(const Graphics::Surface &image, const byte *palette, int palCount) override;
55  void freeImGuiTexture(void *texture) override;
56 #endif
57 
58 #if SDL_VERSION_ATLEAST(2, 0, 0)
59  void destroyingWindow() override;
60 #endif
61 
62 protected:
63  bool loadVideoMode(uint requestedWidth, uint requestedHeight, bool resizable, int antialiasing) override;
64 
65  void refreshScreen() override;
66 
67  void handleResizeImpl(const int width, const int height) override;
68 
69  bool saveScreenshot(const Common::Path &filename) const override;
70 
71  bool canSwitchFullscreen() const override;
72 
73 private:
74  bool setupMode(uint width, uint height);
75 
76  void deinitOpenGLContext();
77 
78 #if SDL_VERSION_ATLEAST(2, 0, 0)
79  int _glContextProfileMask, _glContextMajor, _glContextMinor;
80 
81  SDL_GLContext _glContext;
82 #else
83  uint32 _lastVideoModeLoad;
84 #endif
85 
86 #ifdef EMSCRIPTEN
87 
96  bool _queuedScreenshot = false;
97  void saveScreenshot() override;
98 #endif
99 
100  OpenGL::ContextType _glContextType;
101  bool _resizable;
102  int _requestedAntialiasing;
103  int _effectiveAntialiasing;
104 
105  uint _forceFrameUpdate = 0;
106  uint _lastRequestedWidth;
107  uint _lastRequestedHeight;
108  uint _graphicsScale;
109  bool _gotResize;
110 
111  bool _vsync;
112  bool _wantsFullScreen;
113  uint _ignoreResizeEvents;
114 
115  struct VideoMode {
116  VideoMode() : width(0), height(0) {}
117  VideoMode(uint w, uint h) : width(w), height(h) {}
118 
119  bool operator<(const VideoMode &right) const {
120  if (width < right.width) {
121  return true;
122  } else if (width == right.width && height < right.height) {
123  return true;
124  } else {
125  return false;
126  }
127  }
128 
129  bool operator==(const VideoMode &right) const {
130  return width == right.width && height == right.height;
131  }
132 
133  bool operator!=(const VideoMode &right) const {
134  return !(*this == right);
135  }
136 
137  uint width, height;
138  };
140  VideoModeArray _fullscreenVideoModes;
141 
142  uint _desiredFullscreenWidth;
143  uint _desiredFullscreenHeight;
144 };
145 
146 #endif
void refreshScreen() override
Definition: surface.h:67
Definition: sdl-events.h:40
Definition: sdl-graphics.h:38
Definition: pixelformat.h:138
Feature
Definition: system.h:405
bool canSwitchFullscreen() const override
Definition: path.h:52
bool notifyEvent(const Common::Event &event) override
Definition: openglsdl-graphics.h:32
void handleResizeImpl(const int width, const int height) override
Definition: events.h:210
Definition: opengl-graphics.h:60
void notifyResize(const int width, const int height) override
void notifyVideoExpose() override
bool loadVideoMode(uint requestedWidth, uint requestedHeight, bool resizable, int antialiasing) override
Definition: sdl-window.h:30