Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derived commands #3806

Merged
merged 8 commits into from
Apr 6, 2016
32 changes: 15 additions & 17 deletions Source/Renderer/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,8 @@ define([
gl.clear(bitmask);
};

function beginDraw(context, framebuffer, drawCommand, passState, renderState, shaderProgram) {
var rs = defaultValue(defaultValue(renderState, drawCommand.renderState), context._defaultRenderState);
function beginDraw(context, framebuffer, drawCommand, passState) {
var rs = defaultValue(drawCommand._renderState, context._defaultRenderState);

//>>includeStart('debug', pragmas.debug);
if (defined(framebuffer) && rs.depthTest) {
Expand All @@ -883,16 +883,16 @@ define([

applyRenderState(context, rs, passState, false);

var sp = defaultValue(shaderProgram, drawCommand.shaderProgram);
var sp = drawCommand._shaderProgram;
sp._bind();
context._maxFrameTextureUnitIndex = Math.max(context._maxFrameTextureUnitIndex, sp.maximumTextureUnitIndex);
}

function continueDraw(context, drawCommand, shaderProgram) {
var primitiveType = drawCommand.primitiveType;
var va = drawCommand.vertexArray;
var offset = drawCommand.offset;
var count = drawCommand.count;
function continueDraw(context, drawCommand) {
var primitiveType = drawCommand._primitiveType;
var va = drawCommand._vertexArray;
var offset = drawCommand._offset;
var count = drawCommand._count;
var instanceCount = drawCommand.instanceCount;

//>>includeStart('debug', pragmas.debug);
Expand Down Expand Up @@ -921,9 +921,8 @@ define([
}
//>>includeEnd('debug');

context._us.model = defaultValue(drawCommand.modelMatrix, Matrix4.IDENTITY);
var sp = defaultValue(shaderProgram, drawCommand.shaderProgram);
sp._setUniforms(drawCommand.uniformMap, context._us, context.validateShaderProgram);
context._us.model = defaultValue(drawCommand._modelMatrix, Matrix4.IDENTITY);
drawCommand._shaderProgram._setUniforms(drawCommand._uniformMap, context._us, context.validateShaderProgram);

va._bind();
var indexBuffer = va.indexBuffer;
Expand All @@ -948,23 +947,23 @@ define([
va._unBind();
}

Context.prototype.draw = function(drawCommand, passState, renderState, shaderProgram) {
Context.prototype.draw = function(drawCommand, passState) {
//>>includeStart('debug', pragmas.debug);
if (!defined(drawCommand)) {
throw new DeveloperError('drawCommand is required.');
}

if (!defined(drawCommand.shaderProgram)) {
if (!defined(drawCommand._shaderProgram)) {
throw new DeveloperError('drawCommand.shaderProgram is required.');
}
//>>includeEnd('debug');

passState = defaultValue(passState, this._defaultPassState);
// The command's framebuffer takes presidence over the pass' framebuffer, e.g., for off-screen rendering.
var framebuffer = defaultValue(drawCommand.framebuffer, passState.framebuffer);
var framebuffer = defaultValue(drawCommand._framebuffer, passState.framebuffer);

beginDraw(this, framebuffer, drawCommand, passState, renderState, shaderProgram);
continueDraw(this, drawCommand, shaderProgram);
beginDraw(this, framebuffer, drawCommand, passState);
continueDraw(this, drawCommand);
};

Context.prototype.endFrame = function() {
Expand Down Expand Up @@ -1100,7 +1099,6 @@ define([
* @param {Color} pickColor The pick color.
* @returns {Object} The object associated with the pick color, or undefined if no object is associated with that color.
*
*
* @example
* var object = context.getObjectByPickColor(pickColor);
*
Expand Down
Loading