123456789101112131415161718192021222324252627282930313233343536373839404142 |
- // This is Jeff LaMarche's GLProgram OpenGL shader wrapper class from his OpenGL ES 2.0 book.
- // A description of this can be found at his page on the topic:
- // http://iphonedevelopment.blogspot.com/2010/11/opengl-es-20-for-ios-chapter-4.html
- // I've extended this to be able to take programs as NSStrings in addition to files, for baked-in shaders
- #import <Foundation/Foundation.h>
- #if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
- #import <OpenGLES/ES2/gl.h>
- #import <OpenGLES/ES2/glext.h>
- #else
- #import <OpenGL/OpenGL.h>
- #import <OpenGL/gl.h>
- #endif
- @interface GLProgram : NSObject
- {
- NSMutableArray *attributes;
- NSMutableArray *uniforms;
- GLuint program,
- vertShader,
- fragShader;
- }
- @property(readwrite, nonatomic) BOOL initialized;
- - (id)initWithVertexShaderString:(NSString *)vShaderString
- fragmentShaderString:(NSString *)fShaderString;
- - (id)initWithVertexShaderString:(NSString *)vShaderString
- fragmentShaderFilename:(NSString *)fShaderFilename;
- - (id)initWithVertexShaderFilename:(NSString *)vShaderFilename
- fragmentShaderFilename:(NSString *)fShaderFilename;
- - (void)addAttribute:(NSString *)attributeName;
- - (GLuint)attributeIndex:(NSString *)attributeName;
- - (GLuint)uniformIndex:(NSString *)uniformName;
- - (BOOL)link;
- - (void)use;
- - (NSString *)vertexShaderLog;
- - (NSString *)fragmentShaderLog;
- - (NSString *)programLog;
- - (void)validate;
- @end
|