Skip to content

Commit

Permalink
support external alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
flyover committed Dec 15, 2015
1 parent 07b3cdb commit a751df2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion demo/render-ctx2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ renderCtx2D.prototype.drawPose = function (spine_pose, atlas_data)
ctx.save();

// TODO: slot.color.rgb
ctx.globalAlpha = slot.color.a;
ctx.globalAlpha *= slot.color.a;

switch (slot.blend)
{
Expand Down
5 changes: 5 additions & 0 deletions demo/render-webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ renderWebGL.prototype.drawPose = function (spine_pose, atlas_data)
var gl_tex_matrix = render.gl_tex_matrix;
var gl_color = render.gl_color;

var alpha = gl_color[3];

spine_pose.iterateAttachments(function (slot_key, slot, skin_slot, attachment_key, attachment)
{
if (!attachment) { return; }
Expand All @@ -511,6 +513,7 @@ renderWebGL.prototype.drawPose = function (spine_pose, atlas_data)
mat3x3ApplyAtlasSiteTexcoord(gl_tex_matrix, site);

vec4CopyColor(gl_color, slot.color);
gl_color[3] *= alpha;

gl.enable(gl.BLEND);
switch (slot.blend)
Expand Down Expand Up @@ -781,6 +784,8 @@ renderWebGL.prototype.drawPose = function (spine_pose, atlas_data)
break;
}
});

gl_color[3] = alpha;
}

function vec4Identity (v)
Expand Down

0 comments on commit a751df2

Please sign in to comment.