且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

webgl readpixels总是返回0,0,0,0

更新时间:2021-07-11 05:58:17

根据 WebGL最新规范,你现在需要调用 getContext 设置 preserveDrawingBuffer flag,如:

According to WebGL latest specs, you now need to call getContext setting the preserveDrawingBuffer flag, like:

var ctx = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true});

这可以防止绘图缓冲区(颜色,深度,模板)在绘制到屏幕后被清除。请记住,这可能会导致性能下降。

this prevents the drawing buffer (color, depth, stencil) from being cleared after they are draw to screen. Keep in mind that settings this may cause a performance penalty.