diff --git a/Examples/Simple/iOS/AppDelegate.m b/Examples/Simple/iOS/AppDelegate.m index a0f8e2f8694cc2d779b57f1759eb8a3455a6cd23..ddc177c3e66acdf3e1d02b5c21d0753995adf718 100644 --- a/Examples/Simple/iOS/AppDelegate.m +++ b/Examples/Simple/iOS/AppDelegate.m @@ -31,7 +31,7 @@ * on the same Wi-Fi network. */ - //jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"]; + jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"]; /** * OPTION 2 @@ -43,7 +43,7 @@ * see http://facebook.github.io/react-native/docs/runningondevice.html */ - jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; + //jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"Simple" diff --git a/RNGL/GLCanvas.m b/RNGL/GLCanvas.m index 4e7d4eb73b60be8661728b6dde5d1e1ede0659ae..25ecba7dcd4b97b17d368b7135032f750a04ec95 100644 --- a/RNGL/GLCanvas.m +++ b/RNGL/GLCanvas.m @@ -180,45 +180,51 @@ NSString* srcResource (id res) id value = [data.uniforms objectForKey:uniformName]; GLenum type = [uniformTypes[uniformName] intValue]; - if (value && (type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE)) { + if (type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE) { uniforms[uniformName] = [NSNumber numberWithInt:units++]; - NSString *type = [RCTConvert NSString:value[@"type"]]; - if ([type isEqualToString:@"content"]) { - int id = [[RCTConvert NSNumber:value[@"id"]] intValue]; - if (id >= [_contentTextures count]) { - [self resizeUniformContentTextures:id+1]; - } - textures[uniformName] = _contentTextures[id]; - } - else if ([type isEqualToString:@"framebuffer"]) { - NSNumber *id = [RCTConvert NSNumber:value[@"id"]]; - GLFBO *fbo = [GLShadersRegistry getFBO:id]; - textures[uniformName] = fbo.color[0]; + if (!value) { + GLTexture *emptyTexture = [[GLTexture alloc] init]; + [emptyTexture setPixelsEmpty]; + textures[uniformName] = emptyTexture; } - else if ([type isEqualToString:@"image"]) { - NSObject *val = value[@"value"]; - NSString *src = srcResource(val); - if (!src) { - RCTLogError(@"invalid uniform '%@' texture value '%@'", uniformName, value); + else { + NSString *type = [RCTConvert NSString:value[@"type"]]; + if ([type isEqualToString:@"content"]) { + int id = [[RCTConvert NSNumber:value[@"id"]] intValue]; + if (id >= [_contentTextures count]) { + [self resizeUniformContentTextures:id+1]; + } + textures[uniformName] = _contentTextures[id]; } - - GLImage *image = images[src]; - if (image == nil) { - image = prevImages[src]; - if (image != nil) + else if ([type isEqualToString:@"fbo"]) { + NSNumber *id = [RCTConvert NSNumber:value[@"id"]]; + GLFBO *fbo = [GLShadersRegistry getFBO:id]; + textures[uniformName] = fbo.color[0]; + } + else if ([type isEqualToString:@"uri"]) { + NSString *src = srcResource(value); + if (!src) { + RCTLogError(@"texture uniform '%@': Invalid uri format '%@'", uniformName, value); + } + + GLImage *image = images[src]; + if (image == nil) { + image = prevImages[src]; + if (image != nil) + images[src] = image; + } + if (image == nil) { + image = [[GLImage alloc] initWithBridge:_bridge withOnLoad:^{ + [self onImageLoad:src]; + }]; + image.src = src; images[src] = image; + } + textures[uniformName] = [image getTexture]; } - if (image == nil) { - image = [[GLImage alloc] initWithBridge:_bridge withOnLoad:^{ - [self onImageLoad:src]; - }]; - image.src = src; - images[src] = image; + else { + RCTLogError(@"texture uniform '%@': Unexpected type '%@'", uniformName, type); } - textures[uniformName] = [image getTexture]; - } - else { - RCTLogError(@"invalid uniform '%@' value of type '%@'", uniformName, type); } } else { diff --git a/package.json b/package.json index 81937741e728fadb4f5c7fd037dbda744787b352..565f2fa378d37914c96e1ea2198b32620e24c23a 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "dependencies": { "invariant": "2.1.0", "react-native": ">=0.9.0 <0.12.0", - "gl-react-core": "1.0.0" + "gl-react-core": "git+ssh://git@github.com:ProjectSeptemberInc/gl-react-core.git" }, "devDependencies": { "eslint": "^1.3.1",