1 /* ResidualVM - A 3D game interpreter
2  *
3  * ResidualVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the AUTHORS
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "engines/stark/gfx/openglsfade.h"
24 
25 #include "engines/stark/gfx/opengls.h"
26 
27 #if defined(USE_GLES2) || defined(USE_OPENGL_SHADERS)
28 
29 #include "graphics/opengl/shader.h"
30 
31 namespace Stark {
32 namespace Gfx {
33 
OpenGLSFadeRenderer(OpenGLSDriver * gfx)34 OpenGLSFadeRenderer::OpenGLSFadeRenderer(OpenGLSDriver *gfx) :
35 	FadeRenderer(),
36 	_gfx(gfx) {
37 	_shader = _gfx->createFadeShaderInstance();
38 }
39 
~OpenGLSFadeRenderer()40 OpenGLSFadeRenderer::~OpenGLSFadeRenderer() {
41 	delete _shader;
42 }
43 
render(float fadeLevel)44 void OpenGLSFadeRenderer::render(float fadeLevel) {
45 	_gfx->start2DMode();
46 
47 	_shader->use();
48 	_shader->setUniform1f("alphaLevel", 1.0 - fadeLevel);
49 	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
50 	_shader->unbind();
51 
52 	_gfx->end2DMode();
53 }
54 
55 } // End of namespace Gfx
56 } // End of namespace Stark
57 
58 #endif // defined(USE_GLES2) || defined(USE_OPENGL_SHADERS)
59