2 Copyright 2012 Marten Richter
\r
4 This file is part of VOMP.
\r
6 VOMP is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 VOMP is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with VOMP; if not, write to the Free Software
\r
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
20 #include "glosdshader.h"
\r
22 const GLchar generic_vertex_shader[] =
\r
23 "attribute vec4 vec_pos;\n"
\r
24 "attribute vec2 tex_coord;\n"
\r
25 "varying vec2 out_texCoord;\n"
\r
28 " gl_Position=vec_pos;\n"
\r
29 " out_texCoord=tex_coord;\n"
\r
32 const GLchar osd_frag_shader[] =
\r
33 "precision mediump float;\n"
\r
34 "uniform sampler2D texture;\n"
\r
35 "varying vec2 out_texCoord;\n"
\r
38 " gl_FragColor=texture2D(texture,out_texCoord);\n"
\r
41 GLOsdShader::GLOsdShader(): GLShader("GLOsdShader")
\r
46 GLOsdShader::~GLOsdShader()
\r
48 //parent does everything
\r
51 int GLOsdShader::init()
\r
53 if (!initShaders(generic_vertex_shader,osd_frag_shader)) {
\r
56 osd_sampler_loc=glGetUniformLocation(shad_program,"texture");
\r
61 int GLOsdShader::deinit()
\r
63 return deinitShaders();
\r
66 int GLOsdShader::PrepareRendering(GLuint osd_tex){ // This Function setups the rendering pipeline according to the shaders standards
\r
67 glUseProgram(shad_program);
\r
69 glActiveTexture(GL_TEXTURE0);
\r
70 glBindTexture(GL_TEXTURE_2D,osd_tex);
\r
72 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
\r
73 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
\r
75 glUniform1i(osd_sampler_loc,0);
\r
80 int GLOsdShader::BindAttributes()
\r
82 glBindAttribLocation(shad_program,0,"vec_pos");
\r
83 glBindAttribLocation(shad_program,1,"tex_coord");
\r