Skip to content

Commit 3d40a95

Browse files
committed
Added glFuncMap
1 parent 4c95d69 commit 3d40a95

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Notes:
9797
* There is a new webpack config `FEATURE_SOUND` which is set to `true` by default, but if set to `false` it will exclude the Sound Manager and all of its systems into the build files. Fix #4428 (thanks @goldfire)
9898
* `Scene.Systems.renderer` is a new property that is a reference to the current renderer the game is using.
9999
* `Utils.Objects.SetValue` is a new function that allows you to set a value in an object by specifying a property key. The function can set a value to any depth by using dot-notation for the key, i.e. `SetValue(data, 'world.position.x', 100)`.
100+
* `WebGLRenderer.glFuncMap` is a new object, populated during the `init` method, that contains uniform mappings from key to the corresponding gl function, i.e. `mat2` to `gl.uniformMatrix2fv`.
100101

101102
### Updates
102103

src/renderer/webgl/WebGLRenderer.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,16 @@ var WebGLRenderer = new Class({
506506
*/
507507
this.currentCameraMask = { mask: null, camera: null };
508508

509+
/**
510+
* Internal gl function mapping for uniform look-up.
511+
* https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/uniform
512+
*
513+
* @name Phaser.Renderer.WebGL.WebGLRenderer#glFuncMap
514+
* @type {any}
515+
* @since 3.17.0
516+
*/
517+
this.glFuncMap = null;
518+
509519
this.init(this.config);
510520
},
511521

@@ -571,6 +581,35 @@ var WebGLRenderer = new Class({
571581
this.glFormats[3] = gl.UNSIGNED_SHORT;
572582
this.glFormats[4] = gl.FLOAT;
573583

584+
// Set the gl function map
585+
this.glFuncMap = {
586+
587+
mat2: { func: gl.uniformMatrix2fv, length: 1, matrix: true },
588+
mat3: { func: gl.uniformMatrix3fv, length: 1, matrix: true },
589+
mat4: { func: gl.uniformMatrix4fv, length: 1, matrix: true },
590+
591+
'1f': { func: gl.uniform1f, length: 1 },
592+
'1fv': { func: gl.uniform1fv, length: 1 },
593+
'1i': { func: gl.uniform1i, length: 1 },
594+
'1iv': { func: gl.uniform1iv, length: 1 },
595+
596+
'2f': { func: gl.uniform2f, length: 2 },
597+
'2fv': { func: gl.uniform2fv, length: 1 },
598+
'2i': { func: gl.uniform2i, length: 2 },
599+
'2iv': { func: gl.uniform2iv, length: 1 },
600+
601+
'3f': { func: gl.uniform3f, length: 3 },
602+
'3fv': { func: gl.uniform3fv, length: 1 },
603+
'3i': { func: gl.uniform3i, length: 3 },
604+
'3iv': { func: gl.uniform3iv, length: 1 },
605+
606+
'4f': { func: gl.uniform4f, length: 4 },
607+
'4fv': { func: gl.uniform4fv, length: 1 },
608+
'4i': { func: gl.uniform4i, length: 4 },
609+
'4iv': { func: gl.uniform4iv, length: 1 }
610+
611+
};
612+
574613
// Load supported extensions
575614
var exts = gl.getSupportedExtensions();
576615

0 commit comments

Comments
 (0)