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.
22 GLShader::GLShader(const char* name)
38 int GLShader::initShaders(const char * vertex_shad,const char *fragment_shad)
40 vertex_shader=CreateShader(vertex_shad, GL_VERTEX_SHADER);
41 frag_shader=CreateShader(fragment_shad, GL_FRAGMENT_SHADER);
43 // Create the program for osd rendering
44 shad_program=glCreateProgram();
45 if (shad_program==0) {
46 Log::getInstance()->log("GLShader", Log::WARN, "%s: Creating glsl program failed!%d",objname,glGetError());
49 glAttachShader(shad_program,vertex_shader);
50 glAttachShader(shad_program,frag_shader);
51 if (!BindAttributes()) {
54 glLinkProgram(shad_program);
58 glGetProgramiv(shad_program,GL_LINK_STATUS, &link_status);
62 glGetProgramInfoLog(shad_program,1024,NULL,buffer);
63 Log::getInstance()->log("GLShader", Log::WARN, "%s: Compiling Programm failed!",objname);
64 Log::getInstance()->log("GLShader", Log::WARN, "%s",buffer);
65 glDeleteProgram(shad_program);
71 GLuint GLShader::CreateShader(const GLchar * source, GLenum type)
75 ret_shad=glCreateShader(type);
77 Log::getInstance()->log("GLShader", Log::WARN, "%s: Creating Shader failed! %d",objname, glGetError());
80 glShaderSource(ret_shad,1,&source,NULL);
81 glCompileShader(ret_shad);
83 glGetShaderiv(ret_shad,GL_COMPILE_STATUS, &comp_status);
87 Log::getInstance()->log("GLShader", Log::WARN, "%s: Compiling Shader failed!",objname);
88 glGetShaderInfoLog(ret_shad,1024,NULL,buffer);
89 Log::getInstance()->log("GLShader", Log::WARN, "%s: %s",objname,buffer);
90 glDeleteShader(ret_shad);
96 int GLShader::deinitShaders()
98 if (frag_shader!=0) glDeleteShader(frag_shader);
100 if (vertex_shader!=0) glDeleteShader(vertex_shader);
102 if (shad_program!=0) glDeleteProgram(shad_program);