ScummVM API documentation
framebuffer.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_GRAPHICS_OPENGL_FRAMEBUFFER_H
23#define BACKENDS_GRAPHICS_OPENGL_FRAMEBUFFER_H
24
25#include "graphics/opengl/system_headers.h"
26
27#include "math/matrix4.h"
28
29#include "common/rotationmode.h"
30
31namespace OpenGL {
32
33class Pipeline;
34
39public:
41 virtual ~Framebuffer() {};
42
43public:
44 enum BlendMode {
50
56
62
71
76
82 };
83
87 void setClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
88
93
97 void enableScissorTest(bool enable);
98
102 void setScissorBox(GLint x, GLint y, GLsizei w, GLsizei h);
103
107 const Math::Matrix4 &getProjectionMatrix() const { return _projectionMatrix; }
108
109 enum CopyMask {
110 kCopyMaskClearColor = (1 << 0),
111 kCopyMaskBlendState = (1 << 1),
112 kCopyMaskScissorState = (1 << 2),
113 kCopyMaskScissorBox = (1 << 4),
114
115 kCopyMaskAll = kCopyMaskClearColor | kCopyMaskBlendState |
116 kCopyMaskScissorState | kCopyMaskScissorBox,
117 };
118
122 void copyRenderStateFrom(const Framebuffer &other, uint copyMask);
123
124protected:
125 bool isActive() const { return _pipeline != nullptr; }
126
127 GLint _viewport[4];
128 void applyViewport();
129
130 Math::Matrix4 _projectionMatrix;
131 void applyProjectionMatrix();
132
138 virtual void activateInternal() = 0;
139
146 virtual void deactivateInternal() {}
147
148public:
152 virtual bool setSize(uint width, uint height) = 0;
153
157 void activate(Pipeline *pipeline);
158
163
164private:
165 Pipeline *_pipeline;
166
167 GLfloat _clearColor[4];
168 void applyClearColor();
169
170 BlendMode _blendState;
171 void applyBlendState();
172
173 bool _scissorTestState;
174 void applyScissorTestState();
175
176 GLint _scissorBox[4];
177 void applyScissorBox();
178};
179
183class Backbuffer : public Framebuffer {
184public:
188 bool setSize(uint width, uint height) override;
189
190protected:
191 void activateInternal() override;
192};
193
194#if !USE_FORCED_GLES
195class Texture;
196
204public:
206 ~TextureTarget() override;
207
211 void destroy();
212
216 void create();
217
221 bool setSize(uint width, uint height) override;
222
226 Texture *getTexture() const { return _texture; }
227
228protected:
229 void activateInternal() override;
230
231private:
232 Texture *_texture;
233 GLuint _glFBO;
234 bool _needUpdate;
235};
236#endif
237
238} // End of namespace OpenGL
239
240#endif
Definition: framebuffer.h:183
bool setSize(uint width, uint height) override
void activateInternal() override
Definition: framebuffer.h:38
void activate(Pipeline *pipeline)
virtual void activateInternal()=0
virtual bool setSize(uint width, uint height)=0
void setClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
void setScissorBox(GLint x, GLint y, GLsizei w, GLsizei h)
void enableBlend(BlendMode mode)
void copyRenderStateFrom(const Framebuffer &other, uint copyMask)
BlendMode
Definition: framebuffer.h:44
@ kBlendModeOpaque
Definition: framebuffer.h:55
@ kBlendModeDisabled
Definition: framebuffer.h:49
@ kBlendModePremultipliedTransparency
Definition: framebuffer.h:70
@ kBlendModeAdditive
Definition: framebuffer.h:75
@ kBlendModeTraditionalTransparency
Definition: framebuffer.h:61
@ kBlendModeMaskAlphaAndInvertByColor
Definition: framebuffer.h:81
virtual void deactivateInternal()
Definition: framebuffer.h:146
const Math::Matrix4 & getProjectionMatrix() const
Definition: framebuffer.h:107
void enableScissorTest(bool enable)
Definition: pipeline.h:40
Definition: texture.h:48
Definition: framebuffer.h:203
bool setSize(uint width, uint height) override
Texture * getTexture() const
Definition: framebuffer.h:226
void activateInternal() override