Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
feat (color) add common color feature
Browse files Browse the repository at this point in the history
Also fix corner case webgl render issue with C3 usage of gl scissor.
  • Loading branch information
MikalDev authored and MikalDev committed Mar 1, 2022
1 parent fedb535 commit 8a8a7c7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
Binary file added dist/Spine-v2.2.0.c3addon
Binary file not shown.
2 changes: 1 addition & 1 deletion src/addon.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "plugin",
"name": "Spine",
"id": "Gritsenko_Spine",
"version": "2.1.0",
"version": "2.2.0",
"author": "Mikal and Igor Gritsenko",
"website": "https://gritsenko.github.io/c3_spine_plugin",
"documentation": "https://gritsenko.github.io/c3_spine_plugin",
Expand Down
5 changes: 4 additions & 1 deletion src/c3runtime/spine-draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ class SpineBatch {
gl.enable(gl.BLEND);
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);

// Disable scissor (may be set by C3 renderer)
gl.disable(gl.SCISSOR_TEST);

gl.bindTexture(gl.TEXTURE_2D, null);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
Expand Down Expand Up @@ -347,7 +350,7 @@ class SpineBatch {
// @ts-ignore
if (!globalThis.spineBatcher)
{
console.log('[Spine] SpineBatcher init, 2.1.0, Spine 4.0.x compatible');
console.log('[Spine] SpineBatcher init, 2.2.0, Spine 4.0.x compatible');
// @ts-ignore
globalThis.spineBatcher = new SpineBatch();
}
8 changes: 7 additions & 1 deletion src/c3runtime/spine-gl-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class SpineGLCache {
this._oldViewport = null;
this._isWebGL2 = isWebGL2;
this._gl = gl;
this._scissor = null;
this._scissorBox = null;
}

store() {
Expand Down Expand Up @@ -49,6 +51,8 @@ class SpineGLCache {
this._oldElement = gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING);
this._oldClearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE);
this._oldViewport = gl.getParameter(gl.VIEWPORT);
this._scissor = gl.getParameter(gl.SCISSOR_TEST);
if (this._scissor) this._scissorBox = gl.getParameter(gl.SCISSOR_BOX);
}

restore() {
Expand All @@ -73,7 +77,9 @@ class SpineGLCache {
gl.clearColor(this._oldClearColor[0],this._oldClearColor[1],this._oldClearColor[2],this._oldClearColor[3])
gl.enable(gl.BLEND);
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
gl.viewport(this._oldViewport[0],this._oldViewport[1],this._oldViewport[2],this._oldViewport[3]);
gl.viewport(this._oldViewport[0],this._oldViewport[1],this._oldViewport[2],this._oldViewport[3]);
if (this._scissor) gl.enable(gl.SCISSOR_TEST);
if (this._scissor) gl.scissor(this._scissorBox[0],this._scissorBox[1],this._scissorBox[2],this._scissorBox[3]);
}

// Save C3 webgl context, may be able to reduce some
Expand Down
3 changes: 2 additions & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const C3 = self.C3;

const PLUGIN_ID = "Gritsenko_Spine";
const PLUGIN_VERSION = "2.1.0";
const PLUGIN_VERSION = "2.2.0";
const PLUGIN_CATEGORY = "general";

const PLUGIN_CLASS = SDK.Plugins.Gritsenko_Spine = class SpinePlugin extends SDK.IPluginBase {
Expand All @@ -29,6 +29,7 @@
this._info.AddCommonAppearanceACEs();
this._info.AddCommonZOrderACEs();
this._info.AddCommonSizeACEs();
this._info.SetSupportsColor(true);
this._info.SetIsTiled(false);
this._info.SetIsSingleGlobal(false);
this._info.SetIsDeprecated(false);
Expand Down

0 comments on commit 8a8a7c7

Please sign in to comment.