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 protected:
59  bool loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format) override;
60 
61  void refreshScreen() override;
62 
63  void handleResizeImpl(const int width, const int height) override;
64 
65  bool saveScreenshot(const Common::Path &filename) const override;
66 
67 private:
68  bool setupMode(uint width, uint height);
69 
70 #if SDL_VERSION_ATLEAST(2, 0, 0)
71  int _glContextProfileMask, _glContextMajor, _glContextMinor;
72 
73  SDL_GLContext _glContext;
74 #else
75  uint32 _lastVideoModeLoad;
76 #endif
77 
78 #ifdef EMSCRIPTEN
79 
88  bool _queuedScreenshot = false;
89  void saveScreenshot() override;
90 #endif
91 
92  OpenGL::ContextType _glContextType;
93 
94  uint _forceFrameUpdate = 0;
95  uint _lastRequestedWidth;
96  uint _lastRequestedHeight;
97  uint _graphicsScale;
98  bool _gotResize;
99 
100  bool _vsync;
101  bool _wantsFullScreen;
102  uint _ignoreResizeEvents;
103 
104  struct VideoMode {
105  VideoMode() : width(0), height(0) {}
106  VideoMode(uint w, uint h) : width(w), height(h) {}
107 
108  bool operator<(const VideoMode &right) const {
109  if (width < right.width) {
110  return true;
111  } else if (width == right.width && height < right.height) {
112  return true;
113  } else {
114  return false;
115  }
116  }
117 
118  bool operator==(const VideoMode &right) const {
119  return width == right.width && height == right.height;
120  }
121 
122  bool operator!=(const VideoMode &right) const {
123  return !(*this == right);
124  }
125 
126  uint width, height;
127  };
129  VideoModeArray _fullscreenVideoModes;
130 
131  uint _desiredFullscreenWidth;
132  uint _desiredFullscreenHeight;
133 };
134 
135 #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:403
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:199
Definition: opengl-graphics.h:57
void notifyResize(const int width, const int height) override
void notifyVideoExpose() override
Definition: sdl-window.h:30
bool loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format) override