ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ios-graphics3d.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_GRAPHICS3D_IOS_IOS_GRAPHICS3D_H
23 #define BACKENDS_GRAPHICS3D_IOS_IOS_GRAPHICS3D_H
24 
25 #if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
26 
27 #include "common/scummsys.h"
28 
29 #include "backends/graphics/windowed.h"
30 #include "backends/graphics/ios/ios-graphics.h"
31 #include "backends/graphics3d/opengl/framebuffer.h"
32 #include "backends/graphics3d/opengl/tiledsurface.h"
33 #include "backends/graphics3d/opengl/surfacerenderer.h"
34 
35 class iOSGraphics3dManager : virtual public WindowedGraphicsManager, public iOSCommonGraphics {
36 public:
37  iOSGraphics3dManager();
38  virtual ~iOSGraphics3dManager();
39 
40  //WindowedGraphicsManager
41  bool gameNeedsAspectRatioCorrection() const override;
42  void handleResizeImpl(const int width, const int height) override;
43  virtual void setSystemMousePosition(const int x, const int y) override {};
44 
45  //iOSCommonGraphics
46  void initSurface() override;
47  void deinitSurface() override;
48 
49  void notifyResize(const int width, const int height) override;
50 
51  virtual iOSCommonGraphics::State getState() const override;
52  virtual bool setState(const iOSCommonGraphics::State &state) override;
53 
54  bool notifyMousePosition(Common::Point &mouse) override;
55  Common::Point getMousePosition() override { return Common::Point(_cursorX, _cursorY); }
56 
57  // GraphicsManager API - Features
58  bool hasFeature(OSystem::Feature f) const override;
59  bool getFeatureState(OSystem::Feature f) const override;
60  void setFeatureState(OSystem::Feature f, bool enable) override;
61 
62  const OSystem::GraphicsMode *getSupportedGraphicsModes() const override;
63  int getDefaultGraphicsMode() const override;
64  bool setGraphicsMode(int mode, uint flags = OSystem::kGfxModeNoFlags) override;
65  int getGraphicsMode() const override;
66 
67  void beginGFXTransaction() override {}
68  OSystem::TransactionError endGFXTransaction() override {
70  }
71 
72  // GraphicsManager API - Graphics mode
73 #ifdef USE_RGB_COLOR
74  Graphics::PixelFormat getScreenFormat() const override { return _overlayFormat; }
75  Common::List<Graphics::PixelFormat> getSupportedFormats() const override {
76  Common::List<Graphics::PixelFormat> supportedFormats;
77  return supportedFormats;
78  }
79 #endif
80  int getScreenChangeID() const override { return _screenChangeCount; }
81  void initSize(uint w, uint h, const Graphics::PixelFormat *format) override;
82  int16 getHeight() const override;
83  int16 getWidth() const override;
84 
85  float getHiDPIScreenFactor() const override;
86 
87  // GraphicsManager API - Draw methods
88  void updateScreen() override;
89  // Following methods are not used by 3D graphics managers
90  void setPalette(const byte *colors, uint start, uint num) override {}
91  void grabPalette(byte *colors, uint start, uint num) const override {}
92  void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) override {}
93  Graphics::Surface *lockScreen() override { return nullptr; }
94  void unlockScreen() override {}
95  void fillScreen(uint32 col) override {}
96  void fillScreen(const Common::Rect &r, uint32 col) override {}
97  void setShakePos(int shakeXOffset, int shakeYOffset) override {};
98  void setFocusRectangle(const Common::Rect& rect) override {}
99  void clearFocusRectangle() override {}
100 
101  // GraphicsManager API - Overlay
102  const OSystem::GraphicsMode *getSupportedStretchModes() const override;
103  int getDefaultStretchMode() const override;
104  bool setStretchMode(int mode) override;
105  int getStretchMode() const override;
106  void showOverlay(bool inGUI) override;
107  void hideOverlay() override;
108  Graphics::PixelFormat getOverlayFormat() const override { return _overlayFormat; }
109  void clearOverlay() override;
110  void grabOverlay(Graphics::Surface &surface) const override;
111  void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) override;
112  int16 getOverlayWidth() const override;
113  int16 getOverlayHeight() const override;
114 
115  // GraphicsManager API - Mouse
116  bool showMouse(bool visible) override;
117  void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL, const byte *mask = NULL) override;
118  void setCursorPalette(const byte *colors, uint start, uint num) override {}
119 
120 protected:
121  void updateCursorScaling();
122  void createDepthAndStencilBuffer(int width, int height);
123  void updateDepthAndStencilBuffer(int width, int height);
124 
125  int _screenChangeCount;
126  int _stretchMode;
127  bool _aspectRatioCorrection;
128  bool _mouseDontScale;
129  Common::Point _mouseHotspot;
130  Common::Point _mouseHotspotScaled;
131  int _mouseWidthScaled, _mouseHeightScaled;
132 
133  Graphics::PixelFormat _overlayFormat;
134  OpenGL::TiledSurface *_overlayScreen;
135  OpenGL::TiledSurface *_overlayBackground;
136  OpenGL::TiledSurface *_mouseSurface;
137  OpenGL::SurfaceRenderer *_surfaceRenderer;
138 
139  // FBO used to render games not supporting arbitrary resolutions
140  OpenGL::FrameBuffer *_frameBuffer;
141  // FBO used as a backbuffer for Apple API
142  GLuint _glFBO;
143  // RBOs used for depth and stencil buffer only
144  GLuint _glRBOs[2];
145 };
146 
147 #endif
148 #endif
Definition: ios-graphics.h:30
Definition: surface.h:67
Definition: system.h:779
virtual void setPalette(const byte *colors, uint start, uint num)=0
virtual State getState() const =0
Definition: pixelformat.h:138
Definition: system.h:730
virtual void handleResizeImpl(const int width, const int height)=0
Feature
Definition: system.h:403
virtual bool gameNeedsAspectRatioCorrection() const =0
Definition: list.h:44
Definition: rect.h:144
Definition: ios-graphics.h:50
Definition: windowed.h:52
TransactionError
Definition: system.h:1155
virtual void grabPalette(byte *colors, uint start, uint num) const =0
Definition: rect.h:45
Definition: surfacerenderer.h:37
virtual bool setState(const State &state)=0
Definition: system.h:1156
Definition: tiledsurface.h:40
virtual void setSystemMousePosition(const int x, const int y)=0
virtual void notifyResize(const int width, const int height)=0