Webgl / add support for a time operator in literal styles

This required adding `u_time` as one of the default uniforms provided by the
webgl helper.
This commit is contained in:
Olivier Guyot
2019-10-22 13:39:07 +02:00
parent 0c0c8c5d56
commit 94b8cf6af3
4 changed files with 31 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import WebGLHelper from '../../../../src/ol/webgl/Helper.js';
import WebGLHelper, {DefaultUniform} from '../../../../src/ol/webgl/Helper.js';
import {
create as createTransform,
rotate as rotateTransform,
@@ -11,9 +11,9 @@ import {FLOAT} from '../../../../src/ol/webgl.js';
const VERTEX_SHADER = `
precision mediump float;
uniform mat4 u_projectionMatrix;
uniform mat4 u_offsetScaleMatrix;
uniform mat4 u_offsetRotateMatrix;
uniform float u_time;
attribute float a_test;
uniform float u_test;
@@ -25,9 +25,9 @@ const VERTEX_SHADER = `
const INVALID_VERTEX_SHADER = `
precision mediump float;
uniform mat4 u_projectionMatrix;
uniform mat4 u_offsetScaleMatrix;
uniform mat4 u_offsetRotateMatrix;
uniform float u_time;
bla
uniform float u_test;
@@ -123,6 +123,12 @@ describe('ol.webgl.WebGLHelper', function() {
expect(h.getCanvas().height).to.eql(160);
});
it('has processed default uniforms', function() {
expect(h.uniformLocations_[DefaultUniform.OFFSET_ROTATION_MATRIX]).not.to.eql(undefined);
expect(h.uniformLocations_[DefaultUniform.OFFSET_SCALE_MATRIX]).not.to.eql(undefined);
expect(h.uniformLocations_[DefaultUniform.TIME]).not.to.eql(undefined);
});
it('has processed uniforms', function() {
expect(h.uniforms_.length).to.eql(4);
expect(h.uniforms_[0].name).to.eql('u_test1');