ScummVM API documentation
base_render_opengl3d.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_RENDER_OPENGL3D_H
23#define WINTERMUTE_BASE_RENDER_OPENGL3D_H
24
25#include "engines/wintermute/base/gfx/base_renderer3d.h"
26#include "engines/wintermute/dctypes.h"
27
28#include "graphics/transform_struct.h"
29
30#if defined(USE_OPENGL_GAME)
31
32#include "graphics/opengl/system_headers.h"
33
34namespace Wintermute {
35
36class BaseSurfaceOpenGL3D;
37
38class BaseRenderOpenGL3D : public BaseRenderer3D {
39 friend class BaseSurfaceOpenGL3D;
40 friend class Mesh3DSOpenGL;
41 friend class XMeshOpenGL;
42 friend class ShadowVolumeOpenGL;
43
44 struct SpriteVertex {
45 float x;
46 float y;
47 float z;
48 float u;
49 float v;
50 float r;
51 float g;
52 float b;
53 float a;
54 };
55
56 struct RectangleVertex {
57 float x;
58 float y;
59 float z;
60 };
61
62 struct SimpleShadowVertex {
63 float nx;
64 float ny;
65 float nz;
66 float x;
67 float y;
68 float z;
69 float u;
70 float v;
71 };
72
73public:
74 BaseRenderOpenGL3D(BaseGame *inGame = nullptr);
75 ~BaseRenderOpenGL3D() override;
76
77 bool invalidateTexture(BaseSurface *texture) override;
78
79 bool invalidateDeviceObjects() override;
80 bool restoreDeviceObjects() override;
81
82 bool resetDevice() override;
83
84 void setSpriteBlendMode(Graphics::TSpriteBlendMode blendMode, bool forceChange = false) override;
85
86 void setAmbientLightRenderState() override;
87
88 int getMaxActiveLights() override;
89 void lightEnable(int index, bool enable) override;
90 void setLightParameters(int index, const DXVector3 &position, const DXVector3 &direction, const DXVector4 &diffuse, bool spotlight) override;
91
92 void enableCulling() override;
93 void disableCulling() override;
94
95 bool enableShadows() override;
96 bool disableShadows() override;
97 bool shadowVolumeSupported() override;
98
99 BaseImage *takeScreenshot(int newWidth = 0, int newHeight = 0) override;
100 bool fadeToColor(byte r, byte g, byte b, byte a) override;
101
102 bool flip() override;
103 bool clear() override;
104
105 bool setViewport(int left, int top, int right, int bottom) override;
106 bool drawLine(int x1, int y1, int x2, int y2, uint32 color) override;
107 bool fillRect(int x, int y, int w, int h, uint32 color) override;
108
109 DXMatrix *buildMatrix(DXMatrix* out, const DXVector2 *centre, const DXVector2 *scaling, float angle);
110 void transformVertices(struct SpriteVertex *vertices, const DXVector2 *centre, const DXVector2 *scaling, float angle);
111
112 bool setProjection() override;
113 bool setProjection2D();
114 bool setWorldTransform(const DXMatrix &transform) override;
115 bool setViewTransform(const DXMatrix &transform) override;
116 bool setProjectionTransform(const DXMatrix &transform) override;
117
118 bool initRenderer(int width, int height, bool windowed) override;
119 bool setup2D(bool force = false) override;
120 bool setup3D(Camera3D *camera, bool force = false) override;
121
122 Common::String getName() const override {
123 return "OpenGL 3D renderer";
124 };
125 bool displayDebugInfo() override {
126 return STATUS_FAILED;
127 };
128 bool drawShaderQuad() override {
129 return STATUS_FAILED;
130 }
131
132 float getScaleRatioX() const override {
133 return 1.0f;
134 }
135 float getScaleRatioY() const override {
136 return 1.0f;
137 }
138
139 BaseSurface *createSurface() override;
140
141 bool startSpriteBatch() override;
142 bool endSpriteBatch() override;
143 bool commitSpriteBatch() override;
144
145 bool drawSpriteEx(BaseSurface *texture, const Common::Rect32 &rect, const DXVector2 &pos, const DXVector2 &rot, const DXVector2 &scale,
146 float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) override;
147
148 void renderSceneGeometry(const BaseArray<AdWalkplane *> &planes, const BaseArray<AdBlock *> &blocks,
149 const BaseArray<AdGeneric *> &generics, const BaseArray<Light3D *> &lights, Camera3D *camera) override;
150 void renderShadowGeometry(const BaseArray<AdWalkplane *> &planes, const BaseArray<AdBlock *> &blocks, const BaseArray<AdGeneric *> &generics, Camera3D *camera) override;
151
152 Mesh3DS *createMesh3DS() override;
153 XMesh *createXMesh() override;
154 ShadowVolume *createShadowVolume() override;
155
156 bool setViewport3D(DXViewport *viewport) override;
157
158 void postfilter() override;
159 void setPostfilter(PostFilter postFilter) override { _postFilterMode = postFilter; };
160
161private:
162 bool setupLines();
163 void displaySimpleShadow(BaseObject *object) override;
164
165 Graphics::TSpriteBlendMode _blendMode;
166 SimpleShadowVertex _simpleShadow[4];
167 Common::Array<DXVector4> _lightPositions;
168 Common::Array<DXVector3> _lightDirections;
169 GLuint _postfilterTexture;
170};
171
172} // wintermute namespace
173
174#endif // defined(USE_OPENGL_GAME)
175
176#endif
Definition: array.h:52
Definition: str.h:59
Definition: rect.h:538