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/math/rect32.h"
32 #include "engines/wintermute/base/base.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  virtual void dumpData(const char *filename) {}
66  virtual BaseImage *takeScreenshot() = 0;
67  virtual bool setViewport(int left, int top, int right, int bottom);
68  virtual bool setViewport(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 drawLine(int x1, int y1, int x2, int y2, uint32 color); // Unused outside indicator-display
91  virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); // Unused outside indicator-display
92  BaseRenderer(BaseGame *inGame = nullptr);
93  ~BaseRenderer() override;
94  virtual bool setProjection() {
95  return STATUS_OK;
96  };
97 
98  virtual bool windowedBlt();
106  virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = nullptr) = 0;
107  virtual void onWindowChange();
108  virtual bool initRenderer(int width, int height, bool windowed);
115  virtual bool flip() = 0;
120  virtual bool indicatorFlip() = 0;
121  virtual bool forcedFlip() = 0;
122  virtual void initLoop();
123  virtual bool setup2D(bool force = false);
124 #ifdef ENABLE_WME3D
125  virtual bool setup3D(Camera3D *camera = nullptr, bool force = false);
126 #endif
127  virtual bool setupLines();
128 
134  virtual Common::String getName() const = 0;
135  virtual bool displayDebugInfo() {
136  return STATUS_FAILED;
137  };
138  virtual bool drawShaderQuad() {
139  return STATUS_FAILED;
140  }
141 
142  virtual float getScaleRatioX() const {
143  return 1.0f;
144  }
145  virtual float getScaleRatioY() const {
146  return 1.0f;
147  }
148 
157  virtual BaseSurface *createSurface() = 0;
158 
159  bool clipCursor();
160  bool unclipCursor();
161 
162  BaseObject *getObjectAt(int x, int y);
163  void deleteRectList();
164 
165  virtual bool startSpriteBatch() {
166  return STATUS_OK;
167  };
168  virtual bool endSpriteBatch() {
169  return STATUS_OK;
170  };
171  bool pointInViewport(Point32 *P);
172  bool _active;
173  bool _ready;
174 
175  bool isReady() const { return _ready; }
176  bool isWindowed() const { return _windowed; }
177  int32 getBPP() const { return _bPP; }
178 
179  uint32 _window;
180  uint32 _forceAlphaColor;
181 
182  void addRectToList(BaseActiveRect *rect);
183 
184  // Indicator & Save/Load-related functions
185  void initIndicator();
186  void setIndicatorVal(int value);
187  void setIndicator(int width, int height, int x, int y, uint32 color);
188  void persistSaveLoadImages(BasePersistenceManager *persistMgr);
189  void initSaveLoad(bool isSaving, bool quickSave = false);
190  virtual void endSaveLoad();
191  void setLoadingScreen(const char *filename, int x, int y);
192  void setSaveImage(const char *filename, int x, int y);
193 
194  bool displayIndicator();
195 
196  int32 getWidth() const { return _width; }
197  int32 getHeight() const { return _height; }
198 protected:
199  int32 _height;
200  int32 _width;
201 
202  bool _windowed;
203  int32 _bPP;
204 
205  Common::String _loadImageName;
206  Common::String _saveImageName;
207  int32 _saveImageX;
208  int32 _saveImageY;
209  int32 _loadImageX;
210  int32 _loadImageY;
211  BaseSurface *_saveLoadImage;
212  bool _hasDrawnSaveLoadImage;
213 
214  int32 _indicatorWidthDrawn;
215  uint32 _indicatorColor;
216  int32 _indicatorX;
217  int32 _indicatorY;
218  int32 _indicatorWidth;
219  int32 _indicatorHeight;
220  bool _loadInProgress;
221  bool _indicatorDisplay;
222  int32 _indicatorProgress;
223 
224  uint32 _clipperWindow;
225 
226  Rect32 _windowRect;
227  Rect32 _viewportRect;
228  Rect32 _screenRect;
229  Rect32 _monitorRect;
230 private:
232  bool displaySaveloadImage();
233  bool displaySaveloadLines();
234 };
235 
236 BaseRenderer *makeOSystemRenderer(BaseGame *inGame); // Implemented in BRenderSDL.cpp
237 #ifdef ENABLE_WME3D
238 class BaseRenderer3D;
239 
240 BaseRenderer3D *makeOpenGL3DRenderer(BaseGame *inGame);
241 BaseRenderer3D *makeOpenGL3DShaderRenderer(BaseGame *inGame);
242 #endif
243 
244 } // End of namespace Wintermute
245 
246 #endif
Definition: base_game.h:76
Definition: str.h:59
Definition: base_persistence_manager.h:56
virtual Common::String getName() const =0
Definition: base_image.h:45
Definition: array.h:52
Definition: pixelformat.h:138
virtual BaseSurface * createSurface()=0
Definition: rect32.h:31
Definition: rect.h:144
Definition: base_active_rect.h:41
virtual BaseImage * takeScreenshot()=0
virtual void fade(uint16 alpha)=0
virtual bool indicatorFlip()=0
Definition: rect32.h:60
Definition: base_surface.h:38
Definition: base_renderer3d.h:62
virtual void fadeToColor(byte r, byte g, byte b, byte a)=0
Definition: base_renderer.h:53
Definition: base.h:43
virtual bool flip()=0
Definition: 3dcamera.h:38
virtual bool fill(byte r, byte g, byte b, Common::Rect *rect=nullptr)=0
Definition: base_object.h:49
Definition: achievements_tables.h:27