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

WebGLRenderer: Moved currentProgram to WebGLState.

上级 bdd1d907
......@@ -112,7 +112,6 @@ function WebGLRenderer( parameters ) {
// internal state cache
_currentProgram = null,
_currentRenderTarget = null,
_currentFramebuffer = null,
_currentMaterialId = - 1,
......@@ -316,7 +315,6 @@ function WebGLRenderer( parameters ) {
function resetGLState() {
_currentProgram = null;
_currentCamera = null;
_currentGeometryProgram = '';
......@@ -1676,10 +1674,7 @@ function WebGLRenderer( parameters ) {
p_uniforms = program.getUniforms(),
m_uniforms = materialProperties.shader.uniforms;
if ( program.id !== _currentProgram ) {
_gl.useProgram( program.program );
_currentProgram = program.id;
if ( state.useProgram( program.program ) ) {
refreshProgram = true;
refreshMaterial = true;
......
......@@ -321,6 +321,8 @@ function WebGLState( gl, extensions, paramThreeToGL ) {
var compressedTextureFormats = null;
var currentProgram = null;
var currentBlending = null;
var currentBlendEquation = null;
var currentBlendSrc = null;
......@@ -511,6 +513,22 @@ function WebGLState( gl, extensions, paramThreeToGL ) {
}
function useProgram( program ) {
if ( currentProgram !== program ) {
gl.useProgram( program );
currentProgram = program;
return true;
}
return false;
}
function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) {
if ( blending !== NoBlending ) {
......@@ -878,6 +896,8 @@ function WebGLState( gl, extensions, paramThreeToGL ) {
currentTextureSlot = null;
currentBoundTextures = {};
currentProgram = null;
currentBlending = null;
currentFlipSided = null;
......@@ -906,6 +926,8 @@ function WebGLState( gl, extensions, paramThreeToGL ) {
disable: disable,
getCompressedTextureFormats: getCompressedTextureFormats,
useProgram: useProgram,
setBlending: setBlending,
setMaterial: setMaterial,
......
......@@ -208,7 +208,7 @@ function LensFlarePlugin( renderer, flares ) {
}
gl.useProgram( program );
state.useProgram( program );
state.initAttributes();
state.enableAttribute( attributes.vertex );
......
......@@ -100,7 +100,7 @@ function SpritePlugin( renderer, sprites ) {
}
gl.useProgram( program );
state.useProgram( program );
state.initAttributes();
state.enableAttribute( attributes.position );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册