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 #include "engines/wintermute/math/rect32.h"
29 #include "engines/wintermute/math/vector2.h"
30 
31 #include "graphics/transform_struct.h"
32 #include "graphics/surface.h"
33 
34 #include "math/matrix4.h"
35 #include "math/ray.h"
36 
37 #if defined(USE_OPENGL_SHADERS)
38 
39 #include "graphics/opengl/system_headers.h"
40 
41 #endif
42 
43 namespace Wintermute {
44 
45 class AdBlock;
46 class AdGeneric;
47 class AdWalkplane;
48 class BaseSurfaceOpenGL3D;
49 class Light3D;
50 class Mesh3DS;
51 class XMesh;
52 class ShadowVolume;
53 
54 class BaseRenderer3D : public BaseRenderer {
55 public:
56  BaseRenderer3D(BaseGame *inGame = nullptr);
57  ~BaseRenderer3D() override;
58 
59  bool setAmbientLightColor(uint32 color);
60  bool setDefaultAmbientLightColor();
61  virtual void setAmbientLight() = 0;
62 
63  uint32 _ambientLightColor;
64  bool _overrideAmbientLightColor;
65 
66  virtual int maximumLightsCount() = 0;
67  virtual void enableLight(int index) = 0;
68  virtual void disableLight(int index) = 0;
69  virtual void setLightParameters(int index, const Math::Vector3d &position, const Math::Vector3d &direction,
70  const Math::Vector4d &diffuse, bool spotlight) = 0;
71 
72  virtual void setSpriteBlendMode(Graphics::TSpriteBlendMode blendMode) = 0;
73 
74  virtual void enableCulling() = 0;
75  virtual void disableCulling() = 0;
76 
77  virtual bool enableShadows() = 0;
78  virtual bool disableShadows() = 0;
79  virtual void displayShadow(BaseObject *object, const Math::Vector3d &light, bool lightPosRelative) = 0;
80  virtual bool stencilSupported() = 0;
81 
82  Rect32 getViewPort() override;
83 
84  Graphics::PixelFormat getPixelFormat() const override;
85  void fade(uint16 alpha) override;
86 
87  void initLoop() override;
88 
89  virtual bool setProjection2D() = 0;
90  virtual void setWorldTransform(const Math::Matrix4 &transform) = 0;
91 
92  void project(const Math::Matrix4 &worldMatrix, const Math::Vector3d &point, int32 &x, int32 &y);
93  Math::Ray rayIntoScene(int x, int y);
94 
95  Math::Matrix4 lastProjectionMatrix() {
96  return _projectionMatrix3d;
97  }
98 
99  virtual Mesh3DS *createMesh3DS() = 0;
100  virtual XMesh *createXMesh() = 0;
101  virtual ShadowVolume *createShadowVolume() = 0;
102 
103  bool drawSprite(BaseSurfaceOpenGL3D &tex, const Rect32 &rect, float zoomX, float zoomY, const Vector2 &pos,
104  uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY);
105  virtual bool drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Rect32 &rect, const Vector2 &pos, const Vector2 &rot, const Vector2 &scale,
106  float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) = 0;
107 
108  virtual void renderSceneGeometry(const BaseArray<AdWalkplane *> &planes, const BaseArray<AdBlock *> &blocks,
109  const BaseArray<AdGeneric *> &generics, const BaseArray<Light3D *> &lights, Camera3D *camera) = 0;
110  virtual void renderShadowGeometry(const BaseArray<AdWalkplane *> &planes, const BaseArray<AdBlock *> &blocks, const BaseArray<AdGeneric *> &generics, Camera3D *camera) = 0;
111 
112  Math::Matrix3 build2dTransformation(const Vector2 &center, float angle);
113 
114 protected:
115  Math::Matrix4 _lastViewMatrix;
116  Math::Matrix4 _projectionMatrix3d;
117  Rect32 _viewport3dRect;
118 
119  void flipVertical(Graphics::Surface *s);
120 };
121 
122 } // namespace Wintermute
123 
124 #endif
Definition: base_game.h:75
Definition: surface.h:67
Definition: pixelformat.h:138
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: vector2.h:33
Definition: xmesh.h:48
Definition: rect32.h:60
void fade(uint16 alpha) override
Definition: 3dmesh.h:37
Definition: 3dshadow_volume.h:48
Definition: base_renderer3d.h:54
Definition: coll_templ.h:63
Definition: base_renderer.h:53
Definition: 3dcamera.h:40
Definition: base_object.h:57
Definition: achievements_tables.h:27