Last active
August 29, 2015 14:00
-
-
Save nulldatamap/11143916 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
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