Skip to content

Commit

Permalink
Merge pull request #3806 from AnalyticalGraphicsInc/derived-commands
Browse files Browse the repository at this point in the history
Derived commands
  • Loading branch information
pjcozzi committed Apr 6, 2016
2 parents 2a4cecc + bde897d commit f969382
Show file tree
Hide file tree
Showing 7 changed files with 468 additions and 89 deletions.
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

0 comments on commit f969382

Please sign in to comment.