KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
WebGL is nice and asynchronous in that you can send off a long list of rendering commands without waiting for them to complete. However, if for some reason you do need to wait for the rendering to complete, you have to do it synchronously with gl.finish() . Surely it would be better if gl.finish accepted a callback and returned immediately? Question: Is there any way to emulate this reliably? Usage case: I am rendering a large number of vertices to a large off-screen canvas and then using drawImage to copy sections of this large canvas to small canvases on the page. I don't actually use gl.finish() but drawImage() seems to have the same effect. In my application, re-rendering is only triggered when the user performs an action (e.g. clicking a button), and it may take several hundred milliseconds. It would be nice if during rendering the browser was still responsive allowing scrolling etc. I am looking in particular for a Chrome solution, though something that also works in Firefox and Safari would be good. Possible (bad) answer: You could try and estimate how long rendering is going to take and then set a timeout that begins with the call to gl.finish() . However, reliably doing this estimation for all sizes of vertex buffer and all users is going to be pretty tricky and inaccurate. Possible (non-)answer: requestAnimationFrame does what I'm looking for...it doesn't though, does it? Possible answer in 2018: Perhaps the ImageBitmap API solves this problem - see MDN docs .
Tags (comma-separated)
Save Edits
Cancel