WebGLBackend
The backend rendering code for the web (i.e. in a web browser). Unlike the JVM backend (GLBackend), the WebGLBackend only support a single instance of Window, which uses a html canvas
.
Major difference between WebGL and a regular GL frame buffer :
A WebGL canvas has transparency by default
A WebGL canvas uses pre-multiplied alphas
I really don't want to deal with pre-multiplied alphas, so I've turned this off.
I've read that turning off alpha gives large a performance hit, so I've left it on. Instead, within clear, we ensure the fill color is fully opaque and then turn off the alpha channel with a color mask. I don't know if this is any quicker than turning off alpha completely.
Functions
OpenGL is moe efficient when operations can be batched. So rather than call drawTexture multiple times (with the same texture, tint, and modelMatrix), batch them and call TextureBatch.draw instead.
Clip (scissor). The values are LogicalPixels measured from the TOP left of the window. The clipped region is the intersection of the currently clipped region and the newly requested region.
This must be called only once (i.e. only 1 window is allowed when using the WebGLBackend).
In a JVM context, path is the path of a file (which may be a relative path). The textures are loaded immediately (unlike in a JS context, where there will be a delay).
A gradient fill. Each vertex of each triangle has a color.
If you need to use OpenGL while Glok is rendering a scene, you must perform these actions within a block. This saves the OpenGL state, runs the block, and then restores the state again.