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 struct TextureType {
38  enum type {
39  RGBA8888 = 0,
40  RGB888 = 1,
41  RGB565 = 2,
42  RGBA5551 = 3,
43  RGBA4444 = 4,
44  MAX = 5
45  };
46 };
47 
48 class Renderer {
49 public:
50  Renderer(OSystem *system);
51  virtual ~Renderer();
52 
53  virtual void init() = 0;
54  virtual void deinit() = 0;
55  virtual void clear(const Math::Vector4d &clearColor) = 0;
56 
60  virtual void flipBuffer() { }
61 
62  Common::Rect viewport() const;
63 
64  void setupCameraPerspective(float pitch, float heading, float fov);
65 
66  static const int kOriginalWidth = 640;
67  static const int kOriginalHeight = 480;
68 
69  void computeScreenViewport();
70 
71  virtual void setupViewport(int x, int y, int width, int height) = 0;
72  virtual void loadTextureRGBA(Graphics::Surface *texture) = 0;
73  virtual void loadTextureRGB(Graphics::Surface *texture) = 0;
74  virtual void loadTextureRGB565(Graphics::Surface *texture) = 0;
75  virtual void loadTextureRGBA5551(Graphics::Surface *texture) = 0;
76  virtual void loadTextureRGBA4444(Graphics::Surface *texture) = 0;
77  virtual void drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) = 0;
78  virtual void drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) = 0;
79  virtual void dimRegionInOut(float fade) = 0;
80  virtual void drawInViewport() = 0;
81  virtual void drawRgbaTexture() = 0;
82 
83  virtual void enableFog(const Math::Vector4d &fogColor) = 0;
84  virtual void disableFog() = 0;
85 
86  virtual void enableScissor(int x, int y, int width, int height) = 0;
87  virtual void disableScissor() = 0;
88 
89 protected:
90  OSystem *_system;
91 
92  Common::Rect _screenViewport;
93 
94  Math::Matrix4 _projectionMatrix;
95  Math::Matrix4 _modelViewMatrix;
96  Math::Matrix4 _mvpMatrix;
97 
98  static const float cubeVertices[11 * 6 * 4];
99 
100  Math::Matrix4 makeProjectionMatrix(float fov, float nearClip, float farClip) const;
101 };
102 
103 Renderer *CreateGfxOpenGL(OSystem *system);
104 Renderer *CreateGfxOpenGLShader(OSystem *system);
105 Renderer *CreateGfxTinyGL(OSystem *system);
106 Renderer *createRenderer(OSystem *system);
107 
108 } // End of namespace Playground3d
109 
110 #endif // PLAYGROUND3D_GFX_H
Definition: gfx.h:35
virtual void flipBuffer()
Definition: gfx.h:60
Definition: surface.h:67
Definition: rect.h:524
Definition: gfx.h:48
Definition: gfx.h:37
Definition: system.h:163