ccapture.js
ccapture.js copied to clipboard
Automatically check preserveDrawingBuffer setting?
Hey there! I was having an issue where my .webms were filled with black frames, and the fix was to set preserveDrawingBuffer: true on my webgl context.
It took me quite a while to figure out that this was the issue. I'm wondering how to make this easier to debug. It would be cool if ccapture could auto-detect that your context settings were borked. Maybe something like:
capture(canvas) {
let glContext = canvas.getContext('webgl');
if (glContext && !glContext.getContextAttributes().preserveDrawingBuffer) {
console.warn("Your canvas context does not have preserveDrawingBuffer enabled. You might get black frames!");
}
...
}
Or, if that doesn't sound like a good idea, maybe simply add something to the readme?
Let me know what you think. Am happy to open a PR.