Skip to content

Instantly share code, notes, and snippets.

@nulldatamap
Last active August 29, 2015 14:00
Show Gist options
  • Save nulldatamap/11143916 to your computer and use it in GitHub Desktop.
Save nulldatamap/11143916 to your computer and use it in GitHub Desktop.
// ...
Result<GLuint> scr = compile_shader( false, vertexSource );
if( scr.is_failure() ) {
printf("Engine: Vertex shader failed to compile:\n%s", scr.failure() );
exit( 1 );
}
vertexShader = scr.success();
scr = compile_shader( true, fragSource );
if( scr.is_failure() ) {
printf("Engine: Frag shader failed to compile:\n%s", scr.failure() );
exit( 1 );
}
fragShader = scr.success();
program = glCreateProgram();
if( !program ) {
printf("Engine: Failed to create program\n" );
exit( 1 );
}
glAttachShader( program, vertexShader );
glAttachShader( program, fragShader );
glBindFragDataLocation( program, 0, "outColour" );
glLinkProgram( program );
glUseProgram( program );
GLint posAttrib = glGetAttribLocation( program, "position" );
glEnableVertexAttribArray( posAttrib );
glVertexAttribPointer( posAttrib, 3, GL_FLOAT, GL_FALSE
, 5 * sizeof( float )
, 0 );
GLint texAttrib = glGetAttribLocation( program, "texcoord" );
glEnableVertexAttribArray( texAttrib );
glVertexAttribPointer( texAttrib, 2, GL_FLOAT, GL_FALSE
, 5 * sizeof( float )
, (void*)( 3 * sizeof( float ) ) );
uniTime = glGetUniformLocation( program, "time" );
uniModel = glGetUniformLocation( program, "view" );
uniModel = glGetUniformLocation( program, "model" );
uniModel = glGetUniformLocation( program, "proj" );
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment