解決webgl使用canvas.toDataURL()沒有內容的問題


轉的,記錄一下,我還沒有驗證。

 

 

這個問題很好解決,就是在獲取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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM