This currently only handles basic multi-textured images/sprites
through a basic camera. It forms the basis of a major overhaul.
We assume everything is based on independent quads.
Our shaders are initialized with VAOs,
and drawn using instanced quads.
The buffer memory usage is about 1/6th previous.
Most render systems don't work, and WebGLRenderer is a mess.
That's OK; we just needed to get this committed before it got any
more complicated.
It assumes that programs do not change after creation, so these values
are static, and much can be inferred about their behaviour.
Uniform-setting code is implemented and has been tested on Shader.
Attribute binding has not been finished.
- Change `gl` parameter to `renderer`.
- Remove `WebGLPipeline.activeTextures`, which is now covered by
the more universal TextureUnit system.
- Change TextureUnitsWrapper to only bind `activeTexture` if the texture
is not bound to that unit already.
- Remove `gl.isContextLost` check from `WebGLTextureWrapper`.
The process should run without effect if context is lost,
and we skip fetching data if it is not.
Also tweak several related areas:
- Use `glWrapper` in `PipelineManager.rebind`, making WebGL state
redeclaration more succinct.
- Add `WebGLRenderer.glTextureUnits` property.
- Deprecate `WebGLRenderer.textureindexes` property.
- Simplify WebGL context restoration with `glWrapper`.
- Remove `WebGLRenderer.createTemporaryTextures`.
- Remove texture units and binding from WebGLGlobalParameters.
- Change `WebGLTextureWrapper` to take `renderer` instead of `gl` as its
first parameter. This allows us to use `glWrapper` code internally.
- `WebGLTextureWrapper` currently doesn't unbind textures after use,
which might cause issues with framebuffers etc. We'll ensure that
state management makes this a non-issue.
The Wrapper won't do its job until everything uses wrappers,
but this is a start.
API changes:
- WebGLRenderer.blendModes type is now WebGLBlendParameters[]
instead of untyped array.
- WebGLRenderer.updateBlendMode parameters now specify how to use
separate parameters. The function no longer treats the `equation`
parameter as optional.
This should reduce round-trip calls to the GPU.
We also delete the shaders after they're used.
Spector debug uses the shaders, so we hold onto them if debug is on.
This should make the code lighter and more maintainable.
`UNPACK_FLIP_Y_WEBGL` is now always set, where previously it was allowed
to just remain default (false); this is necessary for the new code path.
`Uint8Array` sources are now allowed to generate MIPMaps.
`WebGLTextureWrapper.update` now checks the type of `pixels`, although
it should only ever be the final case.
This caused an error when calling `Shader.setRenderToTexture()`
after the game started running.
The leftover texture caused a temporary cyclic reference with the new
Framebuffer. The actual rendering pipeline was not affected.