Webgl helper / add the possibility to use transforms as custom uniforms

These will be translated into 4x4 matrices in GLSL.
This commit is contained in:
Olivier Guyot
2019-05-14 15:49:51 +02:00
parent 75eb62363a
commit 3e2e45ce6d
2 changed files with 10 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
import WebGLHelper from '../../../../src/ol/webgl/Helper';
import {create as createTransform} from '../../../../src/ol/transform';
const VERTEX_SHADER = `
@@ -95,7 +96,8 @@ describe('ol.webgl.WebGLHelper', function() {
uniforms: {
u_test1: 42,
u_test2: [1, 3],
u_test3: document.createElement('canvas')
u_test3: document.createElement('canvas'),
u_test4: createTransform()
}
});
h.useProgram(h.getProgram(FRAGMENT_SHADER, VERTEX_SHADER));
@@ -116,13 +118,15 @@ describe('ol.webgl.WebGLHelper', function() {
});
it('has processed uniforms', function() {
expect(h.uniforms_.length).to.eql(3);
expect(h.uniforms_.length).to.eql(4);
expect(h.uniforms_[0].name).to.eql('u_test1');
expect(h.uniforms_[1].name).to.eql('u_test2');
expect(h.uniforms_[2].name).to.eql('u_test3');
expect(h.uniforms_[3].name).to.eql('u_test4');
expect(h.uniforms_[0].location).to.not.eql(-1);
expect(h.uniforms_[1].location).to.not.eql(-1);
expect(h.uniforms_[2].location).to.not.eql(-1);
expect(h.uniforms_[3].location).to.not.eql(-1);
expect(h.uniforms_[2].texture).to.not.eql(undefined);
});
});