I see in the documentation and in other posts here that webgl is the default renderer for the HTML5 target of openfl. I also see some saying it falls back to canvas. I think I see in lime HTML5Renderer createContext where that fallback happens.
However, when I make a simple demo displaying a shape (just using openfl shape, graphics, and sprite classes directly), my browser doesn’t seem to indicate that my demo is utilizing webgl at all. I am using the WebGL Inspector chrome plugin which lights up on most webgl demos, but doesn’t seem to light up on my demo. Ditto in firefox it seems like the canvas snapshot tool only shows 2d calls when I would expect webgl calls of some kind.
I am able to set a breakpoint in createContext and see that webgl does indeed exist, and tracing stage.window.renderer.type says OPENGL.
I can see the shape I created on the stage just fine, but I’m confused why it doesn’t seem to use webgl.
Are there only specific features that activate webgl?
stage.window.renderer.type shows OPENGL, it should be running in WebGL on HTML5.
You could always try a sample like the “BunnyMark” demo, and run it with
openfl test html5 as well as
openfl test html5 -Dcanvas and compare the performance
Thank you for the reply!
I booted up BunnyMark and discovered some interesting things.
In Firefox Developer edition I can see it using webgl calls and printing webgl warnings to the console, so it is obviously using webgl.
In Chrome (56.0.2924.87 (64-bit)), I see in createContext that it is not finding a valid webgl context for some reason, and it is falling back to canvas! This would explain why the chrome WebGL Inspector plugin doesn’t light up.
I suspect that either openfl’s webgl implementation is outdated enough that chrome isn’t recognizing it any more, or I am doing something here (e.g. remote desktop) that is not allowing webgl to work normally in chrome. Either way I think I have my answers.
Yes, it appears that even when webgl is active, some stuff still uses a 2d canvas. My guess (from initial browsing of the openfl code base) is that it uses multiple canvas elements. So you need to draw an image or do something in 3d to actually have webgl calls.
For whatever reason, right now openfl might not be finding a webgl context for some people, but it might be just me.
It is good to know that the fallback to canvas 2d seems to work correctly at least.
Thanks, hope this is useful to others browsing the site!
That happened to me once, but it occurred on all websites, not just OpenFL builds. I had to reboot for this to be resolved, not sure what was going on!
bitmapData operations use canvas, and other things that modify images
Oh good to know, haha, I rarely reboot this machine.
Okay great info, thanks!