Created
September 25, 2010 23:13
-
-
Save DylanLukes/597403 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
- (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]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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);
}