1 /* ResidualVM - A 3D game interpreter
2  *
3  * ResidualVM 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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef BACKENDS_GRAPHICS_SURFACESDL_GRAPHICS_H
24 #define BACKENDS_GRAPHICS_SURFACESDL_GRAPHICS_H
25 
26 #include "backends/graphics/sdl/resvm-sdl-graphics.h"
27 
28 /**
29  * SDL Surface based graphics manager
30  *
31  * Used when rendering the launcher, or games with TinyGL
32  */
33 class SurfaceSdlGraphicsManager : public ResVmSdlGraphicsManager {
34 public:
35 	SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource, SdlWindow *window, const Capabilities &capabilities);
36 	virtual ~SurfaceSdlGraphicsManager();
37 
38 	// GraphicsManager API - Features
39 	virtual bool hasFeature(OSystem::Feature f) override;
40 	virtual void setFeatureState(OSystem::Feature f, bool enable) override;
41 
42 	// GraphicsManager API - Graphics mode
43 	virtual void setupScreen(uint gameWidth, uint gameHeight, bool fullscreen, bool accel3d) override;
44 	virtual Graphics::PixelBuffer getScreenPixelBuffer() override;
45 	virtual int16 getHeight() override;
46 	virtual int16 getWidth() override;
47 
48 	// GraphicsManager API - Draw methods
49 	virtual void updateScreen() override;
50 
51 	// GraphicsManager API - Overlay
52 	virtual void showOverlay() override;
53 	virtual void hideOverlay() override;
54 	virtual void clearOverlay() override;
55 	virtual void grabOverlay(void *buf, int pitch) override;
56 	virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) override;
57 
58 	/* Render the passed Surfaces besides the game texture.
59 	 * This is used for widescreen support in the Grim engine.
60 	 * Note: we must copy the Surfaces, as they are free()d after this call.
61 	 */
62 	virtual void suggestSideTextures(Graphics::Surface *left, Graphics::Surface *right) override;
63 
64 	// GraphicsManager API - Mouse
65 	virtual void warpMouse(int x, int y) override;
66 
67 	// SdlGraphicsManager API
68 	virtual void transformMouseCoordinates(Common::Point &point) override;
69 
70 protected:
71 #if SDL_VERSION_ATLEAST(2, 0, 0)
72 	SDL_Renderer *_renderer;
73 	SDL_Texture *_screenTexture;
74 	void deinitializeRenderer();
75 	SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags);
76 #endif
77 
78 	SDL_Surface *_screen;
79 	SDL_Surface *_subScreen;
80 	void createOrUpdateScreen();
81 
82 	SDL_Surface *_overlayscreen;
83 	bool _overlayDirty;
84 
85 	Math::Rect2d _gameRect;
86 
87 	SDL_Surface *_sideSurfaces[2];
88 
89 	void drawOverlay();
90 	void drawSideTextures();
91 	void closeOverlay();
92 };
93 
94 #endif
95