ScummVM API documentation
base_renderer.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 /*
23  * This file is based on WME Lite.
24  * http://dead-code.org/redir.php?target=wmelite
25  * Copyright (c) 2011 Jan Nedoma
26  */
27 
28 #ifndef WINTERMUTE_BASE_RENDERER_H
29 #define WINTERMUTE_BASE_RENDERER_H
30 
31 #include "engines/wintermute/base/base.h"
32 #include "engines/wintermute/coll_templ.h"
33 
34 #include "common/rect.h"
35 #include "common/array.h"
36 
37 namespace Wintermute {
38 
39 class BaseImage;
40 class BaseActiveRect;
41 class BaseObject;
42 class BaseSurface;
43 class BasePersistenceManager;
44 #ifdef ENABLE_WME3D
45 class Camera3D;
46 #endif
47 
53 class BaseRenderer: public BaseClass {
54 public:
55  int _realWidth;
56  int _realHeight;
57  int _drawOffsetX;
58  int _drawOffsetY;
59 
60  void dumpData(const char *filename) {};
66  virtual BaseImage *takeScreenshot(int newWidth = 0, int newHeight = 0) = 0;
67  virtual bool setViewport(int left, int top, int right, int bottom);
68  virtual bool setViewport(Common::Rect32 *rect);
69  virtual bool setScreenViewport();
70  virtual void setWindowed(bool windowed) = 0;
71 
72  virtual Graphics::PixelFormat getPixelFormat() const = 0;
78  virtual void fade(uint16 alpha) = 0;
88  virtual void fadeToColor(byte r, byte g, byte b, byte a) = 0;
89 
90  virtual bool fillRect(int x, int y, int w, int h, uint32 color); // Unused outside indicator-display
91  BaseRenderer(BaseGame *inGame = nullptr);
92  ~BaseRenderer() override;
93  virtual bool setProjection() {
94  return STATUS_OK;
95  };
96 
97  virtual bool windowedBlt();
101  virtual bool clear() = 0;
102  virtual void onWindowChange();
103  virtual bool initRenderer(int width, int height, bool windowed);
110  virtual bool flip() = 0;
115  virtual bool indicatorFlip() = 0;
116  virtual bool forcedFlip() = 0;
117  virtual void initLoop();
118  virtual bool setup2D(bool force = false);
119 #ifdef ENABLE_WME3D
120  virtual bool setup3D(Camera3D *camera = nullptr, bool force = false);
121 #endif
122 
128  virtual Common::String getName() const = 0;
129  virtual bool displayDebugInfo() {
130  return STATUS_FAILED;
131  };
132  virtual bool drawShaderQuad() {
133  return STATUS_FAILED;
134  }
135 
136  virtual float getScaleRatioX() const {
137  return 1.0f;
138  }
139  virtual float getScaleRatioY() const {
140  return 1.0f;
141  }
142 
151  virtual BaseSurface *createSurface() = 0;
152 
153  bool clipCursor();
154  bool unclipCursor();
155 
156  BaseObject *getObjectAt(int x, int y);
157  void deleteRectList();
158 
159  virtual bool startSpriteBatch() {
160  return STATUS_OK;
161  };
162  virtual bool endSpriteBatch() {
163  return STATUS_OK;
164  };
165  bool pointInViewport(Common::Point32 *P);
166  uint32 _forceAlphaColor;
167  uint32 _window;
168  uint32 _clipperWindow;
169  bool _active;
170  bool _ready;
171 
172  bool isReady() const { return _ready; }
173  bool isWindowed() const { return _windowed; }
174  int32 getBPP() const { return _bPP; }
175 
176 
177  // Indicator & Save/Load-related functions
178  void initIndicator();
179  void setIndicatorVal(int value);
180  void setIndicator(int width, int height, int x, int y, uint32 color);
181  void persistSaveLoadImages(BasePersistenceManager *persistMgr);
182  void initSaveLoad(bool isSaving, bool quickSave = false);
183  virtual void endSaveLoad();
184  void setLoadingScreen(const char *filename, int x, int y);
185  void setSaveImage(const char *filename, int x, int y);
186 
187  bool displayIndicator();
188 
189  int32 getWidth() const { return _width; }
190  int32 getHeight() const { return _height; }
191  bool _windowed;
192  Common::String _loadImageName;
193  Common::String _saveImageName;
194  int32 _saveImageX;
195  int32 _saveImageY;
196  int32 _loadImageX;
197  int32 _loadImageY;
198  BaseSurface *_saveLoadImage;
199  bool _hasDrawnSaveLoadImage;
200 
201  int32 _indicatorWidthDrawn;
202  uint32 _indicatorColor;
203  int32 _indicatorX;
204  int32 _indicatorY;
205  int32 _indicatorWidth;
206  int32 _indicatorHeight;
207  bool _loadInProgress;
208  bool _indicatorDisplay;
209  int32 _indicatorProgress;
210 
211  Common::Rect32 _windowRect;
212  Common::Rect32 _viewportRect;
213  Common::Rect32 _screenRect;
214  Common::Rect32 _monitorRect;
215  int32 _bPP;
216  int32 _height;
217  int32 _width;
218 
219  BaseArray<BaseActiveRect *> _rectList;
220  bool displaySaveloadImage();
221  bool displaySaveloadRect();
222 };
223 
224 BaseRenderer *makeOSystemRenderer(BaseGame *inGame); // Implemented in BRenderSDL.cpp
225 #ifdef ENABLE_WME3D
226 class BaseRenderer3D;
227 
228 BaseRenderer3D *makeOpenGL3DRenderer(BaseGame *inGame);
229 BaseRenderer3D *makeOpenGL3DShaderRenderer(BaseGame *inGame);
230 #endif
231 
232 } // End of namespace Wintermute
233 
234 #endif
Definition: base_game.h:75
Definition: rect.h:526
Definition: str.h:59
Definition: base_persistence_manager.h:55
virtual Common::String getName() const =0
Definition: base_image.h:45
Definition: pixelformat.h:138
virtual BaseSurface * createSurface()=0
virtual bool clear()=0
virtual void fade(uint16 alpha)=0
virtual bool indicatorFlip()=0
virtual BaseImage * takeScreenshot(int newWidth=0, int newHeight=0)=0
Definition: base_surface.h:37
Definition: rect.h:146
Definition: base_renderer3d.h:61
virtual void fadeToColor(byte r, byte g, byte b, byte a)=0
Definition: coll_templ.h:347
Definition: base_renderer.h:53
Definition: base.h:43
virtual bool flip()=0
Definition: 3dcamera.h:38
Definition: base_object.h:49
Definition: achievements_tables.h:27