edu/egl_render_pbuf/main.c
GLuint LoadShader ( GLenum type, const char *shaderSrc )
{
   GLuint shader;
   GLint compiled;
 
   // Create the shader object
   shader = glCreateShader ( type );

   if ( shader == 0 )
    return 0;

   // Load the shader source
   glShaderSource ( shader, 1, &shaderSrc, NULL );
   
   // Compile the shader
   glCompileShader ( shader );

   // Check the compile status
   glGetShaderiv ( shader, GL_COMPILE_STATUS, &compiled );

   if ( !compiled ) 
   {
      GLint infoLen = 0;

      glGetShaderiv ( shader, GL_INFO_LOG_LENGTH, &infoLen );
      
      if ( infoLen > 1 )
      {
         char* infoLog = (char *)malloc (sizeof(char) * infoLen );

         glGetShaderInfoLog ( shader, infoLen, NULL, infoLog );
         fprintf(stderr, "Error compiling shader: %s\n", infoLog);
         
         free ( infoLog );
      }

      glDeleteShader ( shader );
      return 0;
   }

   return shader;
}
///
// Create a shader object, load the shader source, and
// compile the shader.
//
Create a shader object, load the shader source, and
compile the shader.
Create a shader object load the shader source and compile the shader .
GLuint LoadShader ( GLenum type, const char *shaderSrc )
{
   GLuint shader;
   GLint compiled;
   shader = glCreateShader ( type );
   if ( shader == 0 )
    return 0;
   glShaderSource ( shader, 1, &shaderSrc, NULL );
   glCompileShader ( shader );
   glGetShaderiv ( shader, GL_COMPILE_STATUS, &compiled );
   if ( !compiled ) 
   {
      GLint infoLen = 0;
      glGetShaderiv ( shader, GL_INFO_LOG_LENGTH, &infoLen );
      if ( infoLen > 1 )
      {
         char* infoLog = (char *)malloc (sizeof(char) * infoLen );
         glGetShaderInfoLog ( shader, infoLen, NULL, infoLog );
         fprintf(stderr, "Error compiling shader: %s\n", infoLog);
         free ( infoLog );
      }
      glDeleteShader ( shader );
      return 0;
   }
   return shader;
}
GLuint LoadShader ( GLenum type , const char * shaderSrc ) { GLuint shader ; GLint compiled ; shader = glCreateShader ( type ) ; if ( shader == 0 ) return 0 ; glShaderSource ( shader , 1 , & shaderSrc , NULL ) ; glCompileShader ( shader ) ; glGetShaderiv ( shader , GL_COMPILE_STATUS , & compiled ) ; if ( ! compiled ) { GLint infoLen = 0 ; glGetShaderiv ( shader , GL_INFO_LOG_LENGTH , & infoLen ) ; if ( infoLen > 1 ) { char * infoLog = ( char * ) malloc ( sizeof ( char ) * infoLen ) ; glGetShaderInfoLog ( shader , infoLen , NULL , infoLog ) ; fprintf ( stderr , " \n " , infoLog ) ; free ( infoLog ) ; } glDeleteShader ( shader ) ; return 0 ; } return shader ; }
Create a shader object, load the shader source, and
compile the shader.
Create a shader object load the shader source and compile the shader .
// Create the shader object // Load the shader source // Compile the shader // Check the compile status