ScummVM API documentation
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 SLUDGE_GRAPHICS_H
23#define SLUDGE_GRAPHICS_H
24
25#include "sludge/sprbanks.h"
26
27namespace Common {
28class SeekableReadStream;
29class WriteStream;
30}
31
32namespace Sludge {
33
34class Parallax;
35class SludgeEngine;
36class SpritePalette;
37
38struct StackHandler;
39struct FrozenStuffStruct;
40struct LoadedSpriteBank;
41struct OnScreenPerson;
42struct SpriteBank;
43struct Sprite;
44struct VariableStack;
45struct ZBufferData;
46
47enum ELightMapMode {
48 LIGHTMAPMODE_NONE = -1,
49 LIGHTMAPMODE_HOTSPOT,
50 LIGHTMAPMODE_PIXEL,
51 LIGHTMAPMODE_NUM
52};
53
54// Parallax
57 int speedX, speedY;
58 bool wrapS, wrapT;
59 uint16 fileNum, fractionX, fractionY;
60 int cameraX, cameraY;
61};
63
65public:
67 virtual ~GraphicsManager();
68
69 void init();
70 void kill();
71
72 // graphics
73 void setWindowSize(uint winWidth, uint winHeight) { _winWidth = winWidth; _winHeight = winHeight; }
74 bool initGfx();
75 void display();
76 void clear();
77
78 // Parallax
79 bool loadParallax(uint16 v, uint16 fracX, uint16 fracY);
80 void killParallax();
81 void saveParallax(Common::WriteStream *fp);
82 void drawParallax();
83
84 // Backdrop
85 void killAllBackDrop();
86 bool resizeBackdrop(int x, int y);
87 bool killResizeBackdrop(int x, int y);
88 void killBackDrop();
89 void loadBackDrop(int fileNum, int x, int y);
90 void mixBackDrop(int fileNum, int x, int y);
91 void drawBackDrop();
92 void blankScreen(int x1, int y1, int x2, int y2);
93 void blankAllScreen();
94 void darkScreen();
95 void saveHSI(Common::WriteStream *stream);
96 bool loadHSI(int num, Common::SeekableReadStream *stream, int, int, bool);
97 bool mixHSI(int num, Common::SeekableReadStream *stream, int x = 0, int y = 0);
98 void drawLine(uint, uint, uint, uint);
99 void drawHorizontalLine(uint, uint, uint);
100 void drawVerticalLine(uint, uint, uint);
101 void hardScroll(int distance);
102 bool getRGBIntoStack(uint x, uint y, StackHandler *sH);
103 void saveBackdrop(Common::WriteStream *stream); // To game save
104 void loadBackdrop(int ssgVersion, Common::SeekableReadStream *streamn); // From game save
105
106 // Lightmap
107 int _lightMapMode;
108 void killLightMap();
109 bool loadLightMap(int v);
110 void saveLightMap(Common::WriteStream *stream);
111 bool loadLightMap(int ssgVersion, Common::SeekableReadStream *stream);
112
113 // Snapshot
114 void nosnapshot();
115 bool snapshot();
116 void saveSnapshot(Common::WriteStream *stream);
117 bool restoreSnapshot(Common::SeekableReadStream *stream);
118
119 // Camera
120 int getCamX() { return _cameraX; }
121 int getCamY() { return _cameraY; }
122 float getCamZoom() { return _cameraZoom; }
123 void aimCamera(int cameraX, int cameraY);
124 void zoomCamera(int z);
125
126 // Screen
127 int getCenterX(int width) { return (_winWidth - width) >> 1; }
128 int checkSizeValide(int width, int height) { return ((width >= 0) && (height >= 0) && (width < (int)_winWidth) && (height < (int)_winHeight)); }
129
130 // Freeze
131 bool freeze();
132 void unfreeze(bool killImage = true);
133 int howFrozen();
134 bool isFrozen() { return (_frozenStuff != nullptr); }
135
136 // Sprites
137 static void forgetSpriteBank(SpriteBank &forgetme);
138 bool loadSpriteBank(char *filename, SpriteBank &loadhere);
139 bool loadSpriteBank(int fileNum, SpriteBank &loadhere, bool isFont);
140
141 void fontSprite(int x1, int y1, Sprite &single, const SpritePalette &fontPal);
142 void flipFontSprite(int x1, int y1, Sprite &single, const SpritePalette &fontPal);
143
144 bool scaleSprite(Sprite &single, const SpritePalette &fontPal, OnScreenPerson *thisPerson, bool mirror);
145 void fixScaleSprite(int x1, int y1, Sprite &single, const SpritePalette &fontPal, OnScreenPerson *thisPerson, const int camX, const int camY, bool);
146
147 void pasteSpriteToBackDrop(int x1, int y1, Sprite &single, const SpritePalette &fontPal);
148 bool reserveSpritePal(SpritePalette &sP, int n);
149 void burnSpriteToBackDrop(int x1, int y1, Sprite &single, const SpritePalette &fontPal);
150
151 // Sprite Bank
152 LoadedSpriteBank *loadBankForAnim(int ID);
153
154 // ZBuffer
155 bool setZBuffer(int y);
156 void killZBuffer();
157 void drawZBuffer(int x, int y, bool upsidedown);
158 void saveZBuffer(Common::WriteStream *stream);
159 bool loadZBuffer(Common::SeekableReadStream *stream);
160
161 void drawSpriteToZBuffer(int x, int y, uint8 depth, const Graphics::ManagedSurface &surface);
162 void fillZBuffer(uint8 d);
163
164 // Colors
165 void setBlankColor(int r, int g, int b) { _currentBlankColour = _renderSurface.format.RGBToColor(r & 255, g & 255, b & 255);};
166 void setBurnColor(int r, int g, int b) {
167 _currentBurnR = r;
168 _currentBurnG = g;
169 _currentBurnB = b;
170 }
171 void saveColors(Common::WriteStream *stream);
172 void loadColors(Common::SeekableReadStream *stream);
173
174 // Thumbnail
175 bool setThumbnailSize(int thumbWidth, int thumbHeight);
176 bool saveThumbnail(Common::WriteStream *stream);
177 bool skipThumbnail(Common::SeekableReadStream *stream);
178 void showThumbnail(const Common::String &filename, int x, int y);
179
180 // Transition
181 void setBrightnessLevel(int brightnessLevel);
182 void setFadeMode(int fadeMode) { _fadeMode = fadeMode; };
183 void fixBrightness();
184 void resetRandW();
185 void reserveTransitionTexture();
186
187 void transitionFader();
188 void transitionDisolve();
189 void transitionTV();
190 void transitionBlinds();
191 void transitionSnapshotBox();
192 void transitionCrossFader();
193
194 // BG effects
195 bool blurScreen();
196 void blur_saveSettings(Common::WriteStream *stream);
197 void blur_loadSettings(Common::SeekableReadStream *stream);
198 bool blur_createSettings(int numParams, VariableStack *&stack);
199
200 uint getWinWidth() { return _winWidth; }
201 uint getWinHeight() { return _winHeight; }
202
203private:
204 SludgeEngine *_vm;
205
206 uint _winWidth, _winHeight, _sceneWidth, _sceneHeight;
207
208 // renderSurface
209 Graphics::ManagedSurface _renderSurface;
210
211 // Z Buffer Surface
212 uint8 *_zBufferSurface = nullptr;
213
214 // Snapshot
215 Graphics::ManagedSurface _snapshotSurface;
216
217 // LightMap
218 int _lightMapNumber;
219 Graphics::ManagedSurface _lightMap;
220
221 // Camera
222 float _cameraZoom;
223 int _cameraX, _cameraY;
224
225 // Freeze
226 FrozenStuffStruct *_frozenStuff;
227 Graphics::ManagedSurface _freezeSurface;
228 void freezeGraphics();
229
230 // Back drop
231 Graphics::ManagedSurface _backdropSurface;
232 bool _backdropExists;
233 bool reserveBackdrop();
234
235 // Sprites
236 void fontSprite(bool flip, int x, int y, Sprite &single, const SpritePalette &fontPal);
237 Graphics::ManagedSurface *duplicateSurface(Graphics::ManagedSurface *surface);
238 void blendColor(Graphics::ManagedSurface * surface, uint32 color, Graphics::TSpriteBlendMode mode);
239 Graphics::ManagedSurface *applyLightmapToSprite(Graphics::ManagedSurface *&blitted, OnScreenPerson *thisPerson, bool mirror, int x, int y, int x1, int y1, int diffX, int diffY);
240
241 // Sprite banks
242 LoadedSpriteBanks _allLoadedBanks;
243
244 // ZBuffer
245 ZBufferData *_zBuffer;
246 void sortZPal(int *oldpal, int *newpal, int size);
247
248 // Colors
249 uint _currentBlankColour;
250 byte _currentBurnR, _currentBurnG, _currentBurnB;
251
252 // Thumbnail
253 int _thumbWidth;
254 int _thumbHeight;
255
256 // Transition
257 byte _brightnessLevel;
258 byte _fadeMode;
259
260#define RANDKK 17
261
262 uint32 _randbuffer[RANDKK][2];
263 int _randp1, _randp2;
264 Graphics::ManagedSurface *_transitionTexture;
265
266 // Parallax
267 ParallaxLayers *_parallaxLayers;
268
269 inline int sortOutPCamera(int cX, int fX, int sceneMax, int boxMax) {
270 return (fX == 65535) ? (sceneMax ? ((cX * boxMax) / sceneMax) : 0) : ((cX * fX) / 100);
271 }
272};
273
274} // End of namespace Sludge
275
276
277#endif // SLUDGE_GRAPHICS_H
Definition: list.h:44
Definition: stream.h:745
Definition: str.h:59
Definition: stream.h:77
Definition: managed_surface.h:51
PixelFormat & format
Definition: managed_surface.h:137
Definition: graphics.h:64
Definition: sludge.h:70
Definition: sprites.h:34
Definition: algorithm.h:29
uint32 RGBToColor(uint8 r, uint8 g, uint8 b) const
Definition: pixelformat.h:261
Definition: freeze.h:41
Definition: sprbanks.h:28
Definition: people.h:76
Definition: graphics.h:55
Definition: sprites.h:78
Definition: sprites.h:28
Definition: variable.h:60
Definition: variable.h:132
Definition: zbuffer.h:26