转的,记录一下,我还没有验证。
这个问题很好解决,就是在获取webgl对象的时候,多传入一个{preserveDrawingBuffer: true},然后在使用canvas.toDataURL()获取就能够获取到了。
案例:
var canvas = document.getElementById("canvas");
gl = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true});
# https://*.com/questions/26742180/canvas-todataurl-results-in-solid-black-image
# preserveDrawingBuffer: true
# https://*.com/questions/41930000/canvas-todataurl-returns-black-image-in-some-cases?noredirect=1&lq=1
# https://*.com/questions/32556939/saving-canvas-to-image-via-canvas-todataurl-results-in-black-rectangle
# https://www.jianshu.com/p/f3e3e0b663eb
https://blog.csdn.net/harrison2010/article/details/82915929
https://blog.csdn.net/qq_25600055/article/details/77803631