ScummVM API documentation
gfx_opengl_shaders.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 FREESCAPE_GFX_OPENGL_SHADERS_H
23 #define FREESCAPE_GFX_OPENGL_SHADERS_H
24 
25 #include "graphics/opengl/shader.h"
26 #include "graphics/opengl/system_headers.h"
27 #include "math/vector3d.h"
28 #include "math/vector2d.h"
29 
30 #include "freescape/gfx.h"
31 
32 namespace Freescape {
33 
35 public:
36  OpenGLShaderRenderer(int screenW, int screenH, Common::RenderMode renderMode, bool authenticGraphics);
37  virtual ~OpenGLShaderRenderer();
38 
39  Math::Matrix4 _projectionMatrix;
40  Math::Matrix4 _modelViewMatrix;
41  Math::Matrix4 _mvpMatrix;
42 
43  struct Vertex {
44  GLfloat x;
45  GLfloat y;
46  GLfloat z;
47  };
48 
49  void copyToVertexArray(uint idx, const Math::Vector3d &src) {
50  assert(idx < kVertexArraySize);
51  _verts[idx].x = src.x(); _verts[idx].y = src.y(); _verts[idx].z = src.z();
52  }
53 
54  Vertex *_verts;
55 
56  struct Coord {
57  GLfloat x;
58  GLfloat y;
59  };
60 
61  OpenGL::Shader *_triangleShader;
62  OpenGL::Shader *_bitmapShader;
63  OpenGL::Shader *_cubemapShader;
64  GLuint _triangleVBO;
65  GLuint _bitmapVBO;
66  GLuint _cubemapVertVBO;
67  GLuint _cubemapTexCoordVBO;
68  GLuint _cubemapEBO;
69 
70  int _defaultShaderStippleArray[128];
71  int _variableStippleArray[128];
72 
73  virtual void init() override;
74  virtual void clear(uint8 r, uint8 g, uint8 b, bool ignoreViewport = false) override;
75  virtual void setViewport(const Common::Rect &rect) override;
76  virtual Common::Point nativeResolution() override;
77  virtual void positionCamera(const Math::Vector3d &pos, const Math::Vector3d &interest) override;
78  virtual void updateProjectionMatrix(float fov, float aspectRatio, float nearClipPlane, float farClipPlane) override;
79 
80  virtual void useColor(uint8 r, uint8 g, uint8 b) override;
81  virtual void polygonOffset(bool enabled) override;
82  virtual void depthTesting(bool enabled) override;
83 
84  virtual void setStippleData(byte *data) override;
85  virtual void useStipple(bool enabled) override;
86 
87  Texture *createTexture(const Graphics::Surface *surface, bool is3D = false) override;
88  void freeTexture(Texture *texture) override;
89  virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) override;
90 
91  virtual void renderSensorShoot(byte color, const Math::Vector3d sensor, const Math::Vector3d player, const Common::Rect viewPort) override;
92  virtual void renderPlayerShootBall(byte color, const Common::Point position, int frame, const Common::Rect viewPort) override;
93  virtual void renderPlayerShootRay(byte color, const Common::Point position, const Common::Rect viewPort) override;
94  void drawCelestialBody(Math::Vector3d position, float radius, uint8 color) override;
95  void drawSkybox(Texture *texture, Math::Vector3d camera) override;
96 
97  virtual void renderCrossair(const Common::Point crossairPosition) override;
98 
99  virtual void renderFace(const Common::Array<Math::Vector3d> &vertices) override;
100 
101  virtual void flipBuffer() override;
102  virtual void drawFloor(uint8 color) override;
103 
104  virtual Graphics::Surface *getScreenshot() override;
105 };
106 
107 } // End of namespace Freescape
108 
109 #endif // FREESCAPE_GFX_OPENGL_SHADERS_H
Definition: surface.h:67
Definition: area.h:36
virtual void positionCamera(const Math::Vector3d &pos, const Math::Vector3d &interest) override
Definition: gfx_opengl_shaders.h:43
RenderMode
Definition: rendermode.h:48
Definition: rect.h:144
virtual void flipBuffer() override
Definition: gfx_opengl_shaders.h:56
Definition: gfx_opengl_shaders.h:34
Definition: shader.h:56
Definition: gfx.h:60
Definition: rect.h:45
Definition: gfx.h:47