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