提交 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 () {
function fetchUniformLocations( gl, program, identifiers ) {
var uniforms = {};
var n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS );
......@@ -403,7 +402,7 @@ THREE.WebGLProgram = ( function () {
}
if ( haveDiagnostics ) {
this.diagnostics = {
runnable: runnable,
......@@ -436,30 +435,33 @@ THREE.WebGLProgram = ( function () {
// set up caching for uniform locations
var _cachedUniforms;
var getUniforms = function() { return _cachedUniforms; };
var cachedUniforms;
this.getUniforms = function() {
// fetch, cache, and next time just use a dumb accessor
_cachedUniforms = fetchUniformLocations( gl, program );
this.getUniforms = getUniforms;
return _cachedUniforms;
if ( cachedUniforms === undefined ) {
cachedUniforms = fetchUniformLocations( gl, program );
}
return cachedUniforms;
};
// set up caching for attribute locations
var _cachedAttributes;
var getAttributes = function() { return _cachedAttributes; };
var cachedAttributes;
this.getAttributes = function() {
_cachedAttributes = fetchAttributeLocations( gl, program );
this.getAttributes = getAttributes;
return _cachedAttributes;
if ( cachedAttributes === undefined ) {
cachedAttributes = fetchAttributeLocations( gl, program );
}
return cachedAttributes;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册