xcode - Which is the best way to handle OpenGLES shaders as part of an API for iOS? -
working on api ios, wrote couple of shaders important api. these shaders in form of vsh , fsh files. now, working on real projects api , discovered when add folder api source xcode ios project, have additional step, consisting in adding file "copy bundle resources" in build phases tab of project configuration. so, thinking in best way handle issue (and "best" meant step shouldn't exist @ all!) since shaders loaded strings gpu, so, best way handle these shaders in api?
one way avoid having bundle shader files framework or static library embed them string constants. in this project using following macros:
#define stringize(x) #x #define stringize2(x) stringize(x) #define shader_string(text) @ stringize2(text)
this lets me following:
nsstring *const kgpuimagepassthroughfragmentshaderstring = shader_string ( varying highp vec2 texturecoordinate; uniform sampler2d inputimagetexture; void main() { gl_fragcolor = texture2d(inputimagetexture, texturecoordinate); } );
and use nsstring constant provide shader programs needed. shader files not needed, simplifies distribution process.
you don't specific of syntax highlighting in xcode dedicated vertex , fragment shader files, basic c coloring.
Comments
Post a Comment