70                if( glIsShader( shader ) )
 
   73                    glDeleteShader( shader );
 
 
   86    const std::string shaderSource = 
ReadSource( aShaderSourceName );
 
 
   93                                      GLuint geometryOutputType )
 
 
  116        glGetProgramiv( 
programNumber, GL_INFO_LOG_LENGTH, &maxLength );
 
  117        maxLength = maxLength + 1;
 
  118        char* linkInfoLog = 
new char[maxLength];
 
  119        glGetProgramInfoLog( 
programNumber, maxLength, &maxLength, linkInfoLog );
 
  120        std::cerr << 
"Shader linking error:" << std::endl;
 
  121        std::cerr << linkInfoLog;
 
  122        delete[] linkInfoLog;
 
 
  137        throw std::runtime_error( 
"Could not find shader uniform: " + aParameterName );
 
 
  162    float arr[4] = { f0, f1, f2, f3 };
 
 
  171                 static_cast<GLfloat
>( aValue.
y ) );
 
 
  177    return glGetAttribLocation( 
programNumber, aAttributeName.c_str() );
 
 
  183    GLint glInfoLogLength = 0;
 
  184    GLint writtenChars = 0;
 
  187    glGetProgramiv( aProgram, GL_INFO_LOG_LENGTH, &glInfoLogLength );
 
  190    if( glInfoLogLength > 2 )
 
  192        GLchar* glInfoLog = 
new GLchar[glInfoLogLength];
 
  193        glGetProgramInfoLog( aProgram, glInfoLogLength, &writtenChars, glInfoLog );
 
 
  202    GLint glInfoLogLength = 0;
 
  203    GLint writtenChars = 0;
 
  206    glGetShaderiv( aShader, GL_INFO_LOG_LENGTH, &glInfoLogLength );
 
  209    if( glInfoLogLength > 2 )
 
  211        GLchar* glInfoLog = 
new GLchar[glInfoLogLength];
 
  212        glGetShaderInfoLog( aShader, glInfoLogLength, &writtenChars, glInfoLog );
 
 
  222    std::ifstream inputFile( aShaderSourceName.c_str(), std::ifstream::in );
 
  223    std::string   shaderSource;
 
  226        throw std::runtime_error( 
"Can't read the shader source: " + aShaderSourceName );
 
  228    std::string shaderSourceLine;
 
  231    while( getline( inputFile, shaderSourceLine ) )
 
  233        shaderSource += shaderSourceLine;
 
  234        shaderSource += 
"\n";
 
 
  253    GLuint shaderNumber = glCreateShader( aShaderType );
 
  260    glShaderSource( shaderNumber, 
static_cast<GLsizei
>( aSize ), (
const GLchar**) aArray, 
nullptr );
 
  264    glCompileShader( shaderNumber );
 
  266    glGetShaderiv( shaderNumber, GL_COMPILE_STATUS, &status );
 
  268    if( status != GL_TRUE )
 
  273        glGetShaderiv( shaderNumber, GL_INFO_LOG_LENGTH, &maxLength );
 
  276        std::vector<GLchar> errorLog( (
size_t) maxLength );
 
  277        glGetShaderInfoLog( shaderNumber, maxLength, &maxLength, &errorLog[0] );
 
  281        glDeleteShader( shaderNumber ); 
 
  283        throw std::runtime_error( &errorLog[0] );
 
 
static std::string ReadSource(const std::string &aShaderSourceName)
Read the shader source file.
 
bool active
Is any of shaders used?
 
bool LoadShaderFromFile(SHADER_TYPE aShaderType, const std::string &aShaderSourceName)
Load one of the built-in shaders and compiles it.
 
bool isProgramCreated
Flag for program creation.
 
std::deque< GLuint > shaderNumbers
Shader number list.
 
void SetParameter(int aParameterNumber, float aValue) const
Set a parameter of the shader.
 
GLuint geomInputType
Output type [e.g. GL_LINES, GL_TRIANGLES, GL_QUADS etc.].
 
bool loadShaderFromStringArray(SHADER_TYPE aShaderType, const char **aArray, size_t aSize)
Compile vertex of fragment shader source code into the program.
 
std::deque< GLint > parameterLocation
Location of the parameter.
 
GLuint programNumber
Shader program number.
 
bool Link()
Link the shaders.
 
bool isShaderLinked
Is the shader linked?
 
void ConfigureGeometryShader(GLuint maxVertices, GLuint geometryInputType, GLuint geometryOutputType)
Configure the geometry shader - has to be done before linking!
 
bool LoadShaderFromStrings(SHADER_TYPE aShaderType, Args &&... aArgs)
Add a shader and compile the shader sources.
 
void shaderInfo(GLuint aShader)
Get the shader information.
 
void programInfo(GLuint aProgram)
Get the shader program information.
 
int AddParameter(const std::string &aParameterName)
Add a parameter to the parameter queue.
 
GLuint maximumVertices
The maximum of vertices to be generated.
 
int GetAttribute(const std::string &aAttributeName) const
Get an attribute location.
 
void Deactivate()
Deactivate the shader and use the default OpenGL program.
 
The Cairo implementation of the graphics abstraction layer.
 
SHADER_TYPE
Type definition for the shader.
 
@ SHADER_TYPE_GEOMETRY
Geometry shader.
 
VECTOR2< double > VECTOR2D