ScummVM API documentation
surfacerenderer.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 BACKENDS_GRAPHICS3D_OPENGL_SURFACE_RENDERER_H
23 #define BACKENDS_GRAPHICS3D_OPENGL_SURFACE_RENDERER_H
24 
25 #include "math/rect2d.h"
26 
27 #include "graphics/opengl/system_headers.h"
28 
29 namespace OpenGL {
30 
31 class Shader;
32 class TextureGL;
33 
38 public:
40  virtual ~SurfaceRenderer();
41 
45  virtual void prepareState() = 0;
46 
55  virtual void render(const TextureGL *tex, const Math::Rect2d &dest) = 0;
56 
60  virtual void restorePreviousState() = 0;
61 
67  void setFlipY(bool flipY);
68 
72  void enableAlphaBlending(bool enable);
73 
74 protected:
75  bool _flipY;
76  bool _alphaBlending;
77 };
78 
79 #if defined(USE_OPENGL_GAME)
80 
81 class FixedSurfaceRenderer : public SurfaceRenderer {
82 public:
83  virtual ~FixedSurfaceRenderer();
84 
85  // SurfaceRenderer API
86  void prepareState() override;
87  void render(const TextureGL *tex, const Math::Rect2d &dest) override;
88  void restorePreviousState() override;
89 };
90 
91 #endif
92 
93 #if defined(USE_OPENGL_SHADERS)
94 
95 class ShaderSurfaceRenderer : public SurfaceRenderer {
96 public:
97  ShaderSurfaceRenderer();
98  virtual ~ShaderSurfaceRenderer();
99 
100  // SurfaceRenderer API
101  void prepareState() override;
102  void render(const TextureGL *tex, const Math::Rect2d &dest) override;
103  void restorePreviousState() override;
104 
105 private:
106  Shader *_boxShader;
107  GLuint _boxVerticesVBO;
108  GLboolean _prevStateDepthTest;
109  GLboolean _prevStateDepthWriteMask;
110  GLboolean _prevStateBlend;
111  GLboolean _prevStateScissorTest;
112  GLint _prevStateBlendSrcRGB;
113  GLint _prevStateBlendDstRGB;
114  GLint _prevStateBlendSrcAlpha;
115  GLint _prevStateBlendDstAlpha;
116  GLint _prevStateViewport[4];
117 };
118 
119 #endif
120 
121 SurfaceRenderer *createBestSurfaceRenderer();
122 
123 } // End of namespace OpenGL
124 
125 #endif // GRAPHICS_OPENGL_SURFACE_RENDERER_H
void enableAlphaBlending(bool enable)
Definition: shader.h:56
virtual void prepareState()=0
virtual void restorePreviousState()=0
Definition: renderbuffer.h:27
Definition: surfacerenderer.h:37
void setFlipY(bool flipY)
virtual void render(const TextureGL *tex, const Math::Rect2d &dest)=0