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