提交 c052878f 编写于 作者: M Mr.doob

WebGLProgram: Simplified uniforms and attributes caching.

@tschw I think this is the same you were trying to do?
上级 d6890f17
...@@ -22,7 +22,6 @@ THREE.WebGLProgram = ( function () { ...@@ -22,7 +22,6 @@ THREE.WebGLProgram = ( function () {
function fetchUniformLocations( gl, program, identifiers ) { function fetchUniformLocations( gl, program, identifiers ) {
var uniforms = {}; var uniforms = {};
var n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS ); var n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS );
...@@ -436,30 +435,33 @@ THREE.WebGLProgram = ( function () { ...@@ -436,30 +435,33 @@ THREE.WebGLProgram = ( function () {
// set up caching for uniform locations // set up caching for uniform locations
var _cachedUniforms; var cachedUniforms;
var getUniforms = function() { return _cachedUniforms; };
this.getUniforms = function() { this.getUniforms = function() {
// fetch, cache, and next time just use a dumb accessor if ( cachedUniforms === undefined ) {
_cachedUniforms = fetchUniformLocations( gl, program );
this.getUniforms = getUniforms; cachedUniforms = fetchUniformLocations( gl, program );
return _cachedUniforms;
}
return cachedUniforms;
}; };
// set up caching for attribute locations // set up caching for attribute locations
var _cachedAttributes; var cachedAttributes;
var getAttributes = function() { return _cachedAttributes; };
this.getAttributes = function() { this.getAttributes = function() {
_cachedAttributes = fetchAttributeLocations( gl, program ); if ( cachedAttributes === undefined ) {
this.getAttributes = getAttributes;
return _cachedAttributes; cachedAttributes = fetchAttributeLocations( gl, program );
}
return cachedAttributes;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册