September 2018
Intermediate to advanced
472 pages
15h 36m
English
To compile a shader, use the following steps:
GLuint vertShader = glCreateShader( GL_VERTEX_SHADER );
if( 0 == vertShader ) {
std::cerr << "Error creating vertex shader." << std::endl;
exit(EXIT_FAILURE);
}
std::string shaderCode = loadShaderAsString("basic.vert.glsl");
const GLchar * codeArray[] = { shaderCode.c_str() };
glShaderSource( vertShader, 1, codeArray, NULL );
glCompileShader( vertShader );
GLint result;
glGetShaderiv( vertShader, GL_COMPILE_STATUS, &result );
if( GL_FALSE == result ) {
std::cerr << "Vertex shader compilation failed!" << std::endl;
// Get and print the info log GLint ...Read now
Unlock full access