ScummVM API documentation
gfx.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 PLAYGROUND3D_GFX_H
23 #define PLAYGROUND3D_GFX_H
24 
25 #include "common/rect.h"
26 #include "common/system.h"
27 
28 #include "math/frustum.h"
29 #include "math/matrix4.h"
30 #include "math/vector3d.h"
31 
32 #include "graphics/surface.h"
33 #include "graphics/pixelformat.h"
34 
35 namespace Playground3d {
36 
37 class Renderer {
38 public:
39  Renderer(OSystem *system);
40  virtual ~Renderer();
41 
42  virtual void init() = 0;
43  virtual void deinit() = 0;
44  virtual void clear(const Math::Vector4d &clearColor) = 0;
45 
49  virtual void flipBuffer() { }
50 
51  Common::Rect viewport() const;
52 
53  void setupCameraPerspective(float pitch, float heading, float fov);
54 
55  static const int kOriginalWidth = 640;
56  static const int kOriginalHeight = 480;
57 
58  void computeScreenViewport();
59 
60  virtual void setupViewport(int x, int y, int width, int height) = 0;
61  virtual void loadTextureRGBA(Graphics::Surface *texture) = 0;
62  virtual void loadTextureRGB(Graphics::Surface *texture) = 0;
63  virtual void loadTextureRGB565(Graphics::Surface *texture) = 0;
64  virtual void loadTextureRGBA5551(Graphics::Surface *texture) = 0;
65  virtual void loadTextureRGBA4444(Graphics::Surface *texture) = 0;
66  virtual void drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) = 0;
67  virtual void drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) = 0;
68  virtual void dimRegionInOut(float fade) = 0;
69  virtual void drawInViewport() = 0;
70  virtual void drawRgbaTexture() = 0;
71 
72  virtual void enableFog(const Math::Vector4d &fogColor) = 0;
73 
74 protected:
75  OSystem *_system;
76 
77  Common::Rect _screenViewport;
78 
79  Math::Matrix4 _projectionMatrix;
80  Math::Matrix4 _modelViewMatrix;
81  Math::Matrix4 _mvpMatrix;
82 
83  static const float cubeVertices[11 * 6 * 4];
84  Graphics::Surface *_texture;
85 
86  Math::Matrix4 makeProjectionMatrix(float fov, float nearClip, float farClip) const;
87 };
88 
89 Renderer *CreateGfxOpenGL(OSystem *system);
90 Renderer *CreateGfxOpenGLShader(OSystem *system);
91 Renderer *CreateGfxTinyGL(OSystem *system);
92 Renderer *createRenderer(OSystem *system);
93 
94 } // End of namespace Playground3d
95 
96 #endif // PLAYGROUND3D_GFX_H
Definition: gfx.h:35
virtual void flipBuffer()
Definition: gfx.h:49
Definition: surface.h:67
Definition: rect.h:144
Definition: gfx.h:37
Definition: system.h:161