Reactjs 反应本机Webgl闪烁
我正在使用React-Native WebGL()开发一个包含WebGL部分的React-Native应用程序 渲染时出现闪烁问题。我怀疑这与交换RN WebGL使用的WebGLView中的缓冲区和设备的实际帧缓冲区有关 查看RN WebGL GitHub页面上的示例,除了单个帧或使用第三方库(如Three.js)之外,它们似乎都无法正确实现渲染 我正在使用requestAnimationFrame()计划下一个要渲染的帧,并使用gl.flush()和rngl.endFrame()结束帧更新 下面是我更新每个帧的简化代码Reactjs 反应本机Webgl闪烁,reactjs,react-native,webgl,Reactjs,React Native,Webgl,我正在使用React-Native WebGL()开发一个包含WebGL部分的React-Native应用程序 渲染时出现闪烁问题。我怀疑这与交换RN WebGL使用的WebGLView中的缓冲区和设备的实际帧缓冲区有关 查看RN WebGL GitHub页面上的示例,除了单个帧或使用第三方库(如Three.js)之外,它们似乎都无法正确实现渲染 我正在使用requestAnimationFrame()计划下一个要渲染的帧,并使用gl.flush()和rngl.endFrame()结束帧更新 下
const update = () => {
this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
this.gl.viewport(0, 0, this.gl.drawingBufferWidth, this.gl.drawingBufferHeight);
this.shader.Bind(this.gl);
let p = this.shader.GetAttribLocation(this.gl, "p");
if (p > -1) {
this.gl.enableVertexAttribArray(p);
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.buffer);
this.gl.vertexAttribPointer(p, 2, this.gl.FLOAT, false, 0, 0);
}
// Draw entities
this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
this.gl.getError(); // Removing this prevents any rendering at all....
this.gl.flush();
this.rngl.endFrame();
this.requestId = requestAnimationFrame(update);
};
此处可以看到闪烁的视频:
如代码中所述,有一个对gl.getError()的调用;,如果我删除这个调用,那么就根本没有渲染,这是非常奇怪的
任何帮助都将不胜感激