I created my (prize-winning <img src="smileys/smiley2.gif" border="0" align="middle"> ) plugin tutorial using stable release r95. Running it with WebGL switched on (the default) under the latest stable release (r103.2) now produces a JavaScript error ("Type error: ctx is null"). Here's how it happens:
In order to keep things as simple as possible, I simply had a call to instanceProto.drawGL() fall through to instanceProto.draw(), passing this.runtime.overlay_ctx as the context (I'd pinched this code from shinkan's Square plugin):
instanceProto.drawGL = function (glw) {
this.draw(this.runtime.overlay_ctx);
};
However, since r103.2 (or possibly before - I didn't test it with the intervening beta releases), runtime.overlay_ctx returns null.
In any case, when I think about it, overlay_ctx is probably not the right context to be using - my guess is that this creates a second canvas context that simply (no surprise!) overlays the main canvas. What is needed is a reference to the context of that main canvas.
So my question is: how can I access the context that is passed (as ctx) to draw() ? (The answer may be in the SDK manual, but I haven't been able to find it.)