Commit 56e855c1 authored by Nikhilesh Sigatapu's avatar Nikhilesh Sigatapu

add ability to set vertex shader from JS

parent 89c2d7e7
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment