简体   繁体   中英

How do you gently intiailize a WebGL context?

I have a WebGL context in a web application, whenever it intializes it's visible for ~50 000µs as a black square before the (HTML5 appcache) textures become visible and the background becomes transparent.

This using Firefox, which is the sole platform for my application.

How do I get rid of this behaviour? If impossible; how do I work around it?

You can hide canvas with CSS before showing it up. After textures are loaded and you are ready to render.

Use requestAnimFrame for loops it will prevent reflow or redraw before callback function will return execution cursor. So when you are ready to render, start this looping, and in first callback show by css your canvas and render webgl stuff. Once function is done - it will show canvas and render in one single reflow, so no blinks or black frames should appear.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM