轉的,記錄一下,我還沒有驗證。
這個問題很好解決,就是在獲取webgl對象的時候,多傳入一個{preserveDrawingBuffer: true},然后在使用canvas.toDataURL()獲取就能夠獲取到了。
案例:
var canvas = document.getElementById("canvas");
gl = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true});
# https://stackoverflow.com/questions/26742180/canvas-todataurl-results-in-solid-black-image # preserveDrawingBuffer: true # https://stackoverflow.com/questions/41930000/canvas-todataurl-returns-black-image-in-some-cases?noredirect=1&lq=1 # https://stackoverflow.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