From 1eae443ec5903f25cbdff38ae4cd836b8502d888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Tue, 22 Sep 2015 22:13:55 +0200 Subject: [PATCH] changes with latest gl-react-core --- Examples/Simple/iOS/AppDelegate.m | 4 +- RNGL/GLCanvas.m | 72 +++++++++++++++++-------------- package.json | 2 +- 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/Examples/Simple/iOS/AppDelegate.m b/Examples/Simple/iOS/AppDelegate.m index a0f8e2f..ddc177c 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 4e7d4eb..25ecba7 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 8193774..565f2fa 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", -- 2.26.2