]> git.sesse.net Git - mlt/blob - src/modules/opengl/fbo_input.cpp
fafe3339cea406f1da87b1b37a2422f2d13fc693
[mlt] / src / modules / opengl / fbo_input.cpp
1 /*
2  * fbo_input.cpp
3  * Copyright (C) 2013 Dan Dennedy <dan@dennedy.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #include "fbo_input.h"
21 #include <movit/util.h>
22
23 // comes from unexported effect_util.h
24 extern void set_uniform_int(GLuint glsl_program_num, const std::string &prefix, const std::string &key, int value);
25
26 FBOInput::FBOInput(unsigned width, unsigned height)
27         : texture_num(0)
28         , needs_mipmaps(false)
29         , width(width)
30         , height(height)
31 {
32         register_int("needs_mipmaps", &needs_mipmaps);
33 }
34
35 void FBOInput::set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num)
36 {
37         glActiveTexture(GL_TEXTURE0 + *sampler_num);
38         check_error();
39         glBindTexture(GL_TEXTURE_2D, texture_num);
40         check_error();
41
42         // Bind it to a sampler.
43         set_uniform_int(glsl_program_num, prefix, "tex", *sampler_num);
44         ++*sampler_num;
45 }
46
47 std::string FBOInput::output_fragment_shader()
48 {
49         return read_file("flat_input.frag");
50 //      return "uniform sampler2D PREFIX(tex); vec4 FUNCNAME(vec2 tc) { return texture2D(PREFIX(tex), tc); }\n";
51 }