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