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