drawGL() and glwrap.js

For developers using the Construct 2 Javascript SDK

Post » Wed Jan 22, 2014 4:29 am

I'm developing a plugin for my own project and I want draw some stuff. If I would use 2D canvas, that would be easy, because at the moment I need to draw only basic lines / quads. But I'm mainly targeting WebGL, and I figured out how to draw quad while viewing 'Sprite' plugin code, but...

...The major problem is that I see no documentation at all for how to draw in drawGL(). I'm learning raw WebGL simultaneously and I already know basics like vertex buffers, simple shaders for coloring etc. But Construct supplies glwrap.js that should really simplify 2D drawing jobs using WebGL. In the meantime I cannot even figure out how to draw colored quad. Also I don't know how to draw simple line (I know I can draw it like quad, but still). I tried to read glwrap.js code, but it seems quite complicated at first glance.

So, my main question, is there somewhere detailed documentation / tutorial on how to draw in drawGL()? I'd like to know how to draw basic shapes and how to do this in color.
If glwrap doesn't supply simple methods for that, I can do this with raw WebGL calls, but I need to know how to operate buffers and everything to not disrupt regular Construct drawing.
Posts: 2
Reputation: 179

Post » Wed Jan 22, 2014 11:05 am

You can't use raw WebGL calls, it will conflict with the batching glwrap does. I'm afraid we don't have documentation right now though so the best thing to do is to look at plugins. Sprite has a pretty simple drawGL function to just draw a textured quad.
Scirra Founder
Posts: 24,245
Reputation: 192,160

Post » Thu Jan 23, 2014 11:27 am

Thanks for reply! I read glwrap.js more thoroughly and figured out that so far it seems it's possible to only draw textured (or simply black) quads. From shaders code I found that there's no possibility to even make vertex colors. Well, I guess it will be enough for me at the moment to draw only quads, but would like to have more possibilities in future. And documentation, of course =)
Posts: 2
Reputation: 179

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests