From 56e855c11d051dc639cfb383590b9d8655899f58 Mon Sep 17 00:00:00 2001 From: Nikhilesh Sigatapu Date: Tue, 8 Mar 2016 23:34:08 -0800 Subject: [PATCH] add ability to set vertex shader from JS --- ios/RNGLContext.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ios/RNGLContext.m b/ios/RNGLContext.m index 909aac3..75b021b 100644 --- a/ios/RNGLContext.m +++ b/ios/RNGLContext.m @@ -49,13 +49,17 @@ RCT_EXPORT_MODULE() withConfig:(NSDictionary *)config withOnCompile:(RCTResponseSenderBlock)onCompile { + NSString *vert = [RCTConvert NSString:config[@"vert"]]; NSString *frag = [RCTConvert NSString:config[@"frag"]]; NSString *name = [RCTConvert NSString:config[@"name"]]; + if (!vert) { + vert = fullViewportVert; + } if (!frag) { RCTLogError(@"Shader '%@': missing frag field", name); return; } - GLShader *shader = [[GLShader alloc] initWithContext:_context withName:name withVert:fullViewportVert withFrag:frag]; + GLShader *shader = [[GLShader alloc] initWithContext:_context withName:name withVert:vert withFrag:frag]; NSError *error; bool success = [shader ensureCompiles:&error]; if (onCompile) { @@ -112,13 +116,17 @@ NSDictionary* glTypesString (NSDictionary *types) { RCT_EXPORT_METHOD(addShader:(nonnull NSNumber *)id withConfig:(NSDictionary *)config withOnCompile:(RCTResponseSenderBlock)onCompile) { + NSString *vert = [RCTConvert NSString:config[@"vert"]]; NSString *frag = [RCTConvert NSString:config[@"frag"]]; NSString *name = [RCTConvert NSString:config[@"name"]]; + if (!vert) { + vert = fullViewportVert; + } if (!frag) { RCTLogError(@"Shader '%@': missing frag field", name); return; } - GLShader *shader = [[GLShader alloc] initWithContext:_context withName:name withVert:fullViewportVert withFrag:frag]; + GLShader *shader = [[GLShader alloc] initWithContext:_context withName:name withVert:vert withFrag:frag]; NSError *error; bool success = [shader ensureCompiles:&error]; if (onCompile) { @@ -158,4 +166,4 @@ RCT_EXPORT_METHOD(removeShader:(nonnull NSNumber *)id) { return [self moduleForClass:[RNGLContext class]]; } -@end \ No newline at end of file +@end -- 2.26.2