Skip to content

Commit 38e6203

Browse files
committed
Add unit test for WebGL shader version method
1 parent 2ceef3b commit 38e6203

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

test/unit/webgl/p5.Shader.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,29 @@ suite('p5.Shader', function() {
244244
var curShader = myp5._renderer.states.userFillShader;
245245
assert.isTrue(curShader === null);
246246
});
247+
test('version() detects a #version directive', function() {
248+
const shader = myp5.createShader(
249+
`
250+
#version 300 es
251+
precision highp float;
252+
attribute vec3 aPosition;
253+
uniform mat4 uModelViewMatrix;
254+
uniform mat4 uProjectionMatrix;
255+
256+
void main() {
257+
gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(aPosition, 1.0);
258+
}
259+
`,
260+
`
261+
precision highp float;
262+
263+
void main() {
264+
gl_FragColor = vec4(1.0);
265+
}
266+
`
267+
);
268+
assert.strictEqual(shader.version(), '300 es');
269+
});
247270
suite('Hooks', function() {
248271
let myShader;
249272
beforeEach(function() {

0 commit comments

Comments
 (0)