Skip to content

Instantly share code, notes, and snippets.

@DylanLukes
Created September 25, 2010 23:13
Show Gist options
  • Save DylanLukes/597403 to your computer and use it in GitHub Desktop.
Save DylanLukes/597403 to your computer and use it in GitHub Desktop.
- (void)loadShaderNamed:(NSString*)shaderName buffer:(const GLchar**)buffer length:(GLuint*)length{
NSURL *url;
NSString *shader;
NSError *error;
NSDictionary *errorInfo;
url = [self URLForResource:shaderName withExtension:nil subdirectory:@"Shaders"];
shader = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error];
if (!shader) {
errorInfo = [NSDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat:@"Shader \"%@\" could not be loaded.", shaderName],
NSLocalizedDescriptionKey,
[NSString stringWithFormat:@"Does \"%@\" exist?", shaderName],
NSLocalizedRecoverySuggestionErrorKey,
nil];
error = [NSError errorWithDomain:@"com.dlukes.cglutil" code:1 userInfo:errorInfo];
[NSApp presentError:error];
return;
}
NSLog(@"%@", shader);
*buffer = [shader UTF8String];
*length = [shader lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
}
@DylanLukes
Copy link
Author

version 110

attribute vec2 position;

varying vec2 texcoord;

void main()
{
gl_Position = vec4(position, 0.0, 1.0);
texcoord = position * vec2(0.5) + vec2(0.5);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment