Oversight in Node-Webkit exporter

For developers using the Construct 2 Javascript SDK

Post » Fri Nov 14, 2014 2:44 am

@Ashley, i was wondering about why transparent backgrounds / "alpha canvas" is disabled in nodewebkit, specifically around line 329 in preview.js right before the renderer is created. I understand that alpha "doesn't work in nodewebkit", but my plugin, and perhaps others in the future, need to modify the z-index of the construct canvas to use it as a 2D overlay. I enabled alpha canvas for nodewebkit by disabling the flag, and truly nothing changes except the fact i can then use the construct 2 canvas as an overlay within node-webkit. It's an anti-feature to the node-webkit exporter to disable it this way, and right now the only way around it is for me to tell users they have to disable it for a particular basic option of my plugin to work in tandem with construct 2 in node-webkit.
B
79
S
13
G
8
Posts: 1,977
Reputation: 9,947

Post » Fri Nov 14, 2014 2:43 pm

Turning off alpha is a performance optimisation, which apparently can make a difference to fillrate-limited devices. It means the backing canvas doesn't have an alpha channel so the alpha components don't need to be filled or processed or composited to the screen. On platforms where there is typically nothing that can appear behind the canvas then the runtime sets this mode to allow the browser to optimise it if possible. This isn't limited to node-webkit - it's also used on Windows Store, Crosswalk and PhoneGap apps for the same reason.

I guess your plugin needs to force alpha enabled on all platforms, but I don't want to just turn it off completely since that could de-optimise it even when unnecessary. So for the next build (in r188) I added a flag in the runtime you can use to force alpha mode enabled: set runtime.forceCanvasAlpha to true. You have to set that in the plugin or type constructor, since by the time you get to an instance's constructor/onCreate it's already read the value to initialise the renderer.
Scirra Founder
B
403
S
238
G
89
Posts: 24,654
Reputation: 196,155

Post » Fri Nov 14, 2014 4:15 pm

Awesome thanks!
B
79
S
13
G
8
Posts: 1,977
Reputation: 9,947


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests