GLProgram.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // This is Jeff LaMarche's GLProgram OpenGL shader wrapper class from his OpenGL ES 2.0 book.
  2. // A description of this can be found at his page on the topic:
  3. // http://iphonedevelopment.blogspot.com/2010/11/opengl-es-20-for-ios-chapter-4.html
  4. // I've extended this to be able to take programs as NSStrings in addition to files, for baked-in shaders
  5. #import <Foundation/Foundation.h>
  6. #if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
  7. #import <OpenGLES/ES2/gl.h>
  8. #import <OpenGLES/ES2/glext.h>
  9. #else
  10. #import <OpenGL/OpenGL.h>
  11. #import <OpenGL/gl.h>
  12. #endif
  13. @interface GLProgram : NSObject
  14. {
  15. NSMutableArray *attributes;
  16. NSMutableArray *uniforms;
  17. GLuint program,
  18. vertShader,
  19. fragShader;
  20. }
  21. @property(readwrite, nonatomic) BOOL initialized;
  22. - (id)initWithVertexShaderString:(NSString *)vShaderString
  23. fragmentShaderString:(NSString *)fShaderString;
  24. - (id)initWithVertexShaderString:(NSString *)vShaderString
  25. fragmentShaderFilename:(NSString *)fShaderFilename;
  26. - (id)initWithVertexShaderFilename:(NSString *)vShaderFilename
  27. fragmentShaderFilename:(NSString *)fShaderFilename;
  28. - (void)addAttribute:(NSString *)attributeName;
  29. - (GLuint)attributeIndex:(NSString *)attributeName;
  30. - (GLuint)uniformIndex:(NSString *)uniformName;
  31. - (BOOL)link;
  32. - (void)use;
  33. - (NSString *)vertexShaderLog;
  34. - (NSString *)fragmentShaderLog;
  35. - (NSString *)programLog;
  36. - (void)validate;
  37. @end