ScummVM API documentation
base_renderer3d.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 WINTERMUTE_BASE_RENDERER_3D_H
23#define WINTERMUTE_BASE_RENDERER_3D_H
24
25#include "engines/wintermute/base/gfx/base_renderer.h"
26#include "engines/wintermute/coll_templ.h"
27#include "engines/wintermute/dctypes.h"
28
29#include "graphics/transform_struct.h"
30#include "graphics/surface.h"
31
32#if defined(USE_OPENGL_SHADERS)
33
34#include "graphics/opengl/system_headers.h"
35
36#include "engines/wintermute/base/gfx/xmath.h"
37
38#endif
39
40namespace Wintermute {
41
42class AdBlock;
43class AdGeneric;
44class AdWalkplane;
45class BaseSurfaceOpenGL3D;
46class Light3D;
47class Mesh3DS;
48class XMesh;
49class ShadowVolume;
50
51#define DEFAULT_NEAR_PLANE 90.0f
52#define DEFAULT_FAR_PLANE 10000.0f
53
54enum PostFilter {
55 kPostFilterOff,
56 kPostFilterBlackAndWhite,
57 kPostFilterSepia
58};
59
61public:
62 BaseRenderer3D(BaseGame *inGame = nullptr);
63 ~BaseRenderer3D() override;
64
65 bool getProjectionParams(float *resWidth, float *resHeight, float *layerWidth, float *layerHeight,
66 float *modWidth, float *modHeight, bool *customViewport);
67 virtual int getMaxActiveLights() = 0;
68
69 bool setAmbientLightColor(uint32 color);
70 bool setDefaultAmbientLightColor();
71
72 uint32 _ambientLightColor;
73 bool _ambientLightOverride;
74
75 void dumpData(const char *filename) {};
76 bool setup3DCustom(DXMatrix &viewMat, DXMatrix &projMat);
77 virtual bool enableShadows() = 0;
78 virtual bool disableShadows() = 0;
79 virtual bool shadowVolumeSupported() = 0;
80 virtual bool invalidateTexture(BaseSurface *texture) = 0;
81
82 virtual void setSpriteBlendMode(Graphics::TSpriteBlendMode blendMode, bool forceChange = false) = 0;
83
84 virtual bool invalidateDeviceObjects() = 0;
85 virtual bool restoreDeviceObjects() = 0;
86 BaseSurface *_lastTexture;
87 bool fade(uint16 alpha) override;
88 bool drawSprite(BaseSurface *texture, const Common::Rect32 &rect, float zoomX, float zoomY, const DXVector2 &pos,
89 uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY);
90 virtual bool drawSpriteEx(BaseSurface *texture, const Common::Rect32 &rect, const DXVector2 &pos, const DXVector2 &rot, const DXVector2 &scale,
91 float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) = 0;
92 Camera3D *_camera;
93 virtual bool resetDevice() = 0;
94 void initLoop() override;
95 bool windowedBlt() override;
96
97 virtual bool startSpriteBatch() override = 0;
98 virtual bool endSpriteBatch() override = 0;
99 virtual bool commitSpriteBatch() = 0;
100
101
102 // ScummVM specific methods -->
103
104 virtual void lightEnable(int index, bool enable) = 0;
105 virtual void setLightParameters(int index, const DXVector3 &position, const DXVector3 &direction,
106 const DXVector4 &diffuse, bool spotlight) = 0;
107
108 virtual void enableCulling() = 0;
109 virtual void disableCulling() = 0;
110
111 DXViewport getViewPort();
112
113 void setWindowed(bool windowed) override;
114 void onWindowChange() override;
115
116 Graphics::PixelFormat getPixelFormat() const override;
117
118 virtual bool setWorldTransform(const DXMatrix &transform) = 0;
119 virtual bool setViewTransform(const DXMatrix &transform) = 0;
120 virtual bool setProjectionTransform(const DXMatrix &transform) = 0;
121
122 void getWorldTransform(DXMatrix *transform) {
123 *transform = _worldMatrix;
124 }
125
126 void getViewTransform(DXMatrix *transform) {
127 *transform = _viewMatrix;
128 }
129
130 void getProjectionTransform(DXMatrix *transform) {
131 *transform = _projectionMatrix;
132 }
133
134 virtual Mesh3DS *createMesh3DS() = 0;
135 virtual XMesh *createXMesh() = 0;
136 virtual ShadowVolume *createShadowVolume() = 0;
137
138
139 virtual void renderSceneGeometry(const BaseArray<AdWalkplane *> &planes, const BaseArray<AdBlock *> &blocks,
140 const BaseArray<AdGeneric *> &generics, const BaseArray<Light3D *> &lights, Camera3D *camera) = 0;
141 virtual void renderShadowGeometry(const BaseArray<AdWalkplane *> &planes, const BaseArray<AdBlock *> &blocks, const BaseArray<AdGeneric *> &generics, Camera3D *camera) = 0;
142
143 virtual void displaySimpleShadow(BaseObject *object) = 0;
144
145 virtual void postfilter() = 0;
146 virtual void setPostfilter(PostFilter postFilter) = 0;
147 bool flip() override;
148 bool indicatorFlip(int32 x, int32 y, int32 width, int32 height) override;
149 bool forcedFlip() override;
150 virtual bool setViewport3D(DXViewport *viewport) = 0;
151
152 void invalidateLastTexture() {
153 _lastTexture = nullptr;
154 }
155
156 void endSaveLoad() override;
157
158 void setBrightnessOknytt(int32 brightness) {
159 _brightnessOknytt = brightness;
160 }
161 float getBrightnessOknytt() {
162 return _brightnessOknytt;
163 }
164 void setBrightnessJulia(float brightness) {
165 _brightnessJulia = brightness;
166 }
167
168 // ScummVM specific methods <--
169
170protected:
171 DXMatrix _worldMatrix;
172 DXMatrix _viewMatrix;
173 DXMatrix _projectionMatrix;
174 DXViewport _viewport{};
175 float _fov;
176 float _nearClipPlane;
177 float _farClipPlane;
178 TRendererState _state;
179 PostFilter _postFilterMode;
180 bool _flipInProgress;
181 int32 _brightnessOknytt;
182 float _brightnessJulia;
183
184 virtual void setAmbientLightRenderState() = 0;
185};
186
187} // namespace Wintermute
188
189#endif
Definition: base_game.h:79
Definition: base_renderer3d.h:60
bool indicatorFlip(int32 x, int32 y, int32 width, int32 height) override
bool fade(uint16 alpha) override
Definition: base_renderer.h:53
Definition: base_surface.h:37
Definition: 3dcamera.h:38
Definition: rect.h:538
Definition: pixelformat.h:138
Definition: xmath.h:139
Definition: xmath.h:42
Definition: xmath.h:72
Definition: xmath.h:101
Definition: xmath.h:162