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() ...@@ -49,13 +49,17 @@ RCT_EXPORT_MODULE()
withConfig:(NSDictionary *)config withConfig:(NSDictionary *)config
withOnCompile:(RCTResponseSenderBlock)onCompile withOnCompile:(RCTResponseSenderBlock)onCompile
{ {
NSString *vert = [RCTConvert NSString:config[@"vert"]];
NSString *frag = [RCTConvert NSString:config[@"frag"]]; NSString *frag = [RCTConvert NSString:config[@"frag"]];
NSString *name = [RCTConvert NSString:config[@"name"]]; NSString *name = [RCTConvert NSString:config[@"name"]];
if (!vert) {
vert = fullViewportVert;
}
if (!frag) { if (!frag) {
RCTLogError(@"Shader '%@': missing frag field", name); RCTLogError(@"Shader '%@': missing frag field", name);
return; 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; NSError *error;
bool success = [shader ensureCompiles:&error]; bool success = [shader ensureCompiles:&error];
if (onCompile) { if (onCompile) {
...@@ -112,13 +116,17 @@ NSDictionary* glTypesString (NSDictionary *types) { ...@@ -112,13 +116,17 @@ NSDictionary* glTypesString (NSDictionary *types) {
RCT_EXPORT_METHOD(addShader:(nonnull NSNumber *)id RCT_EXPORT_METHOD(addShader:(nonnull NSNumber *)id
withConfig:(NSDictionary *)config withConfig:(NSDictionary *)config
withOnCompile:(RCTResponseSenderBlock)onCompile) { withOnCompile:(RCTResponseSenderBlock)onCompile) {
NSString *vert = [RCTConvert NSString:config[@"vert"]];
NSString *frag = [RCTConvert NSString:config[@"frag"]]; NSString *frag = [RCTConvert NSString:config[@"frag"]];
NSString *name = [RCTConvert NSString:config[@"name"]]; NSString *name = [RCTConvert NSString:config[@"name"]];
if (!vert) {
vert = fullViewportVert;
}
if (!frag) { if (!frag) {
RCTLogError(@"Shader '%@': missing frag field", name); RCTLogError(@"Shader '%@': missing frag field", name);
return; 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; NSError *error;
bool success = [shader ensureCompiles:&error]; bool success = [shader ensureCompiles:&error];
if (onCompile) { if (onCompile) {
......
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