1 /***************************************************************************
3 * Copyright 2010,2011 BMW Car IT GmbH
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ****************************************************************************/
20 #ifndef BEAGLESHADERPROGRAM_H_
21 #define BEAGLESHADERPROGRAM_H_
23 #include <ShaderProgram.h>
24 #include <GLES2/gl2.h>
27 /// pointer to shader program creator function
28 typedef ShaderProgram* (*PfnShaderProgramCreator)(const std::string&, const std::string&);
31 * Factory for creating platform specific shader programs.
33 class ShaderProgramBeagle : public ShaderProgram
37 * Create a new shader program.
39 * @param vertName File name of vertex shader.
40 * @param fragName File name of fragment shader.
41 * @return new Program instance, NULL if program could not be created.
43 static ShaderProgram* createProgram(const std::string& vertName, const std::string& fragName);
48 virtual ~ShaderProgramBeagle(void);
51 * Start using the shader program for rendering.
53 virtual void use(void) const;
55 virtual int getUniformLocation(const char* name) const
57 return glGetUniformLocation(_progHandle, name);
60 virtual void uniform1iv(int location, int count, const int* v) const
62 glUniform1iv(location, count, v);
65 virtual void uniform1fv(int location, int count, const float* v) const
67 glUniform1fv(location, count, v);
70 virtual void uniform2fv(int location, int count, const float* v) const
72 glUniform2fv(location, count, v);
75 virtual void uniform3fv(int location, int count, const float* v) const
77 glUniform3fv(location, count, v);
80 virtual void uniform4fv(int location, int count, const float* v) const
82 glUniform4fv(location, count, v);
85 virtual void uniformMatrix2fv(int location, int count, bool transpose, const float* v) const
87 glUniformMatrix2fv(location, count, transpose, v);
90 virtual void uniformMatrix3fv(int location, int count, bool transpose, const float* v) const
92 glUniformMatrix3fv(location, count, transpose, v);
95 virtual void uniformMatrix4fv(int location, int count, bool transpose, const float* v) const
97 glUniformMatrix4fv(location, count, transpose, v);
102 * Protected constructor.
103 * New instances of this class are supposed to be created by ShaderProgramBeagle::createProgram.
105 * @param vertName File name of vertex shader.
106 * @param fragName File name of fragment shader.
108 ShaderProgramBeagle(const std::string& vertName, const std::string& fragName, GLuint handle);
111 /// OpenGL ES program handle
115 #endif /* BEAGLESHADERPROGRAM_H_ */