Commit 7619f92f authored by Gaëtan Renaudeau's avatar Gaëtan Renaudeau

Workaround to force the redraw when there are targets

parent 1d73e9ad
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
}, },
"dependencies": { "dependencies": {
"gl-react-native": "file:../..", "gl-react-native": "file:../..",
"react-native": "^0.9.0" "react-native": "^0.10.0"
} }
} }
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
@property (nonatomic) GLData *data; @property (nonatomic) GLData *data;
@property (nonatomic) BOOL opaque; @property (nonatomic) BOOL opaque;
@property (nonatomic) NSNumber *nbTargets; @property (nonatomic) NSNumber *nbTargets;
@property (nonatomic) NSNumber *renderId;
- (instancetype)initWithBridge:(RCTBridge *)bridge - (instancetype)initWithBridge:(RCTBridge *)bridge
withContext:(EAGLContext*)context; withContext:(EAGLContext*)context;
......
...@@ -61,6 +61,13 @@ NSString* srcResource (id res) ...@@ -61,6 +61,13 @@ NSString* srcResource (id res)
return src; return src;
} }
- (void)setRenderId:(NSNumber *)renderId
{
if (_nbTargets > 0) {
[self setNeedsDisplay];
}
}
- (void)setData:(GLData *)data - (void)setData:(GLData *)data
{ {
_data = data; _data = data;
...@@ -94,7 +101,7 @@ NSString* srcResource (id res) ...@@ -94,7 +101,7 @@ NSString* srcResource (id res)
for (GLData *child in data.children) { for (GLData *child in data.children) {
if (fboId == frameIndex) fboId ++; if (fboId == frameIndex) fboId ++;
fbosMapping[[NSNumber numberWithInt:i]] = [NSNumber numberWithInt:fboId]; fbosMapping[[NSNumber numberWithInt:i]] = [NSNumber numberWithInt:fboId];
[children addObject:traverseTree(child, fboId)]; [children addObject:weak_traverseTree(child, fboId)];
fboId ++; fboId ++;
i ++; i ++;
} }
...@@ -180,6 +187,7 @@ NSString* srcResource (id res) ...@@ -180,6 +187,7 @@ NSString* srcResource (id res)
- (void)setNbTargets:(NSNumber *)nbTargets - (void)setNbTargets:(NSNumber *)nbTargets
{ {
[self resizeTargets:[nbTargets intValue]]; [self resizeTargets:[nbTargets intValue]];
_nbTargets = nbTargets;
} }
- (void)resizeTargets:(int)n - (void)resizeTargets:(int)n
...@@ -245,7 +253,7 @@ NSString* srcResource (id res) ...@@ -245,7 +253,7 @@ NSString* srcResource (id res)
float h = [renderData.height floatValue] * scale; float h = [renderData.height floatValue] * scale;
for (GLRenderData *child in renderData.children) for (GLRenderData *child in renderData.children)
recDraw(child); weak_recDraw(child);
if (renderData.frameIndex == -1) { if (renderData.frameIndex == -1) {
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
......
...@@ -21,6 +21,7 @@ RCT_EXPORT_MODULE(); ...@@ -21,6 +21,7 @@ RCT_EXPORT_MODULE();
RCT_EXPORT_VIEW_PROPERTY(nbTargets, NSNumber); RCT_EXPORT_VIEW_PROPERTY(nbTargets, NSNumber);
RCT_EXPORT_VIEW_PROPERTY(opaque, BOOL); RCT_EXPORT_VIEW_PROPERTY(opaque, BOOL);
RCT_EXPORT_VIEW_PROPERTY(data, GLData); RCT_EXPORT_VIEW_PROPERTY(data, GLData);
RCT_EXPORT_VIEW_PROPERTY(renderId, NSNumber);
- (UIView *)view - (UIView *)view
{ {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
"dependencies": { "dependencies": {
"invariant": "2.1.0", "invariant": "2.1.0",
"react-native": ">=0.9.0 <0.11.0", "react-native": ">=0.9.0 <0.11.0",
"gl-react-core": "^0.1.0" "gl-react-core": "^0.1.1"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^1.2.1", "eslint": "^1.2.1",
......
...@@ -23,13 +23,14 @@ const renderVtarget = function (style, width, height, id, children) { ...@@ -23,13 +23,14 @@ const renderVtarget = function (style, width, height, id, children) {
return <View style={[ childrenStyle, style ]}>{children}</View>; return <View style={[ childrenStyle, style ]}>{children}</View>;
}; };
const renderVGL = function (props, width, height, data, nbTargets) { const renderVGL = function (props, width, height, data, nbTargets, renderId) {
return <GLCanvas return <GLCanvas
ref="native" ref="native"
{...props} {...props}
style={{ ...props.style, width, height }} style={{ ...props.style, width, height }}
data={data} data={data}
nbTargets={nbTargets} nbTargets={nbTargets}
renderId={renderId}
/>; />;
}; };
......
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