mirror of
https://github.com/MapMakersAndProgrammers/Alternativa3D.git
synced 2025-10-26 09:59:10 -07:00
Call times of setProgram(), setBlendMode, setCulling() reduced
This commit is contained in:
@@ -121,8 +121,15 @@ package alternativa.engine3d.core {
|
||||
}
|
||||
|
||||
protected function renderDrawUnit(drawUnit:DrawUnit, context:Context3D, camera:Camera3D):void {
|
||||
context.setBlendFactors(drawUnit.blendSource, drawUnit.blendDestination);
|
||||
context.setCulling(drawUnit.culling);
|
||||
if (_contextProperties.blendSource != drawUnit.blendSource || _contextProperties.blendDestination != drawUnit.blendDestination) {
|
||||
context.setBlendFactors(drawUnit.blendSource, drawUnit.blendDestination);
|
||||
_contextProperties.blendSource = drawUnit.blendSource;
|
||||
_contextProperties.blendDestination = drawUnit.blendDestination;
|
||||
}
|
||||
if (_contextProperties.culling != drawUnit.culling) {
|
||||
context.setCulling(drawUnit.culling);
|
||||
_contextProperties.culling = drawUnit.culling;
|
||||
}
|
||||
var _usedBuffers:uint = _contextProperties.usedBuffers;
|
||||
var _usedTextures:uint = _contextProperties.usedTextures;
|
||||
|
||||
@@ -152,7 +159,10 @@ package alternativa.engine3d.core {
|
||||
_usedTextures &= ~textureBit;
|
||||
context.setTextureAt(textureSampler, drawUnit.textures[i]);
|
||||
}
|
||||
context.setProgram(drawUnit.program);
|
||||
if (_contextProperties.program != drawUnit.program) {
|
||||
context.setProgram(drawUnit.program);
|
||||
_contextProperties.program = drawUnit.program;
|
||||
}
|
||||
for (bufferIndex = 0; _usedBuffers > 0; bufferIndex++) {
|
||||
bufferBit = _usedBuffers & 1;
|
||||
_usedBuffers >>= 1;
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
package alternativa.engine3d.core {
|
||||
|
||||
import flash.display3D.Program3D;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Stores settings of context.
|
||||
@@ -17,5 +19,10 @@ package alternativa.engine3d.core {
|
||||
public var usedBuffers:uint = 0;
|
||||
public var usedTextures:uint = 0;
|
||||
|
||||
public var program:Program3D;
|
||||
public var culling:String;
|
||||
public var blendSource:String;
|
||||
public var blendDestination:String;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user