ScummVM API documentation
renderer3d.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_RENDERER3D_H
23#define BACKENDS_GRAPHICS_OPENGL_RENDERER3D_H
24
25#include "common/scummsys.h"
26
27#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
28
29#include "graphics/opengl/texture.h"
30
31namespace OpenGL {
32
33class Renderer3D {
34public:
35 Renderer3D();
36 ~Renderer3D() { destroy(); }
37
38 void initSize(uint w, uint h, int samples, bool renderToFrameBuffer);
39 void resize(uint w, uint h);
40 void recreate();
41 void destroy();
42
43 void leave3D();
44 void enter3D();
45 void presentBuffer();
46
47 void showOverlay(uint w, uint h);
48 void hideOverlay();
49
50 const Texture &getGLTexture() const { return _texture; }
51 bool hasTexture() const { return _texture.getGLTexture() != 0; }
52
53 void setRotation(Common::RotationMode rotation) { _texture.setRotation(rotation); }
54
55protected:
56 void setup();
57
58 int _stackLevel;
59 bool _inOverlay;
60 int _pendingScreenChangeWidth;
61 int _pendingScreenChangeHeight;
62
63 bool _renderToFrameBuffer;
64 int _samples;
65 Texture _texture;
66 GLuint _renderBuffers[3];
67 GLuint _frameBuffers[2];
68
69#define CTX_STATE(gl_param) GLboolean _save ## gl_param = false
70#define CTX_BOOLEAN(gl_param) GLboolean _save ## gl_param = false
71#define CTX_INTEGER(gl_param, count) GLint _save ## gl_param[count] = { 0 }
72
73 CTX_STATE(GL_BLEND);
74 CTX_STATE(GL_CULL_FACE);
75 CTX_STATE(GL_DEPTH_TEST);
76 CTX_STATE(GL_DITHER);
77 CTX_STATE(GL_POLYGON_OFFSET_FILL);
78 CTX_STATE(GL_SCISSOR_TEST);
79 CTX_STATE(GL_STENCIL_TEST);
80
81 CTX_BOOLEAN(GL_DEPTH_WRITEMASK);
82
83 CTX_INTEGER(GL_BLEND_SRC_RGB, 1);
84 CTX_INTEGER(GL_BLEND_DST_RGB, 1);
85 CTX_INTEGER(GL_BLEND_SRC_ALPHA, 1);
86 CTX_INTEGER(GL_BLEND_DST_ALPHA, 1);
87 CTX_INTEGER(GL_SCISSOR_BOX, 4);
88 CTX_INTEGER(GL_VIEWPORT, 4);
89
90#undef CTX_INTEGER
91#undef CTX_BOOLEAN
92#undef CTX_STATE
93};
94
95} // End of namespace OpenGL
96
97#endif // defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
98
99#endif
RotationMode
Definition: rotationmode.h:44