Skip to content

Commit

Permalink
[ts][webgl] SceneRenderer method to draw textures with manually set UVs.
Browse files Browse the repository at this point in the history
  • Loading branch information
badlogic committed Nov 17, 2017
1 parent 99b975f commit 246c531
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 3 deletions.
1 change: 1 addition & 0 deletions spine-ts/build/spine-all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,7 @@ declare module spine.webgl {
drawSkeleton(skeleton: Skeleton, premultipliedAlpha?: boolean): void;
drawSkeletonDebug(skeleton: Skeleton, premultipliedAlpha?: boolean, ignoredBones?: Array<string>): void;
drawTexture(texture: GLTexture, x: number, y: number, width: number, height: number, color?: Color): void;
drawTextureUV(texture: GLTexture, x: number, y: number, width: number, height: number, u: number, v: number, u2: number, v2: number, color?: Color): void;
drawTextureRotated(texture: GLTexture, x: number, y: number, width: number, height: number, pivotX: number, pivotY: number, angle: number, color?: Color, premultipliedAlpha?: boolean): void;
drawRegion(region: TextureAtlasRegion, x: number, y: number, width: number, height: number, color?: Color, premultipliedAlpha?: boolean): void;
line(x: number, y: number, x2: number, y2: number, color?: Color, color2?: Color): void;
Expand Down
65 changes: 65 additions & 0 deletions spine-ts/build/spine-all.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spine-ts/build/spine-all.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions spine-ts/build/spine-webgl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,7 @@ declare module spine.webgl {
drawSkeleton(skeleton: Skeleton, premultipliedAlpha?: boolean): void;
drawSkeletonDebug(skeleton: Skeleton, premultipliedAlpha?: boolean, ignoredBones?: Array<string>): void;
drawTexture(texture: GLTexture, x: number, y: number, width: number, height: number, color?: Color): void;
drawTextureUV(texture: GLTexture, x: number, y: number, width: number, height: number, u: number, v: number, u2: number, v2: number, color?: Color): void;
drawTextureRotated(texture: GLTexture, x: number, y: number, width: number, height: number, pivotX: number, pivotY: number, angle: number, color?: Color, premultipliedAlpha?: boolean): void;
drawRegion(region: TextureAtlasRegion, x: number, y: number, width: number, height: number, color?: Color, premultipliedAlpha?: boolean): void;
line(x: number, y: number, x2: number, y2: number, color?: Color, color2?: Color): void;
Expand Down
65 changes: 65 additions & 0 deletions spine-ts/build/spine-webgl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spine-ts/build/spine-webgl.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions spine-ts/build/spine-widget.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,7 @@ declare module spine.webgl {
drawSkeleton(skeleton: Skeleton, premultipliedAlpha?: boolean): void;
drawSkeletonDebug(skeleton: Skeleton, premultipliedAlpha?: boolean, ignoredBones?: Array<string>): void;
drawTexture(texture: GLTexture, x: number, y: number, width: number, height: number, color?: Color): void;
drawTextureUV(texture: GLTexture, x: number, y: number, width: number, height: number, u: number, v: number, u2: number, v2: number, color?: Color): void;
drawTextureRotated(texture: GLTexture, x: number, y: number, width: number, height: number, pivotX: number, pivotY: number, angle: number, color?: Color, premultipliedAlpha?: boolean): void;
drawRegion(region: TextureAtlasRegion, x: number, y: number, width: number, height: number, color?: Color, premultipliedAlpha?: boolean): void;
line(x: number, y: number, x2: number, y2: number, color?: Color, color2?: Color): void;
Expand Down
65 changes: 65 additions & 0 deletions spine-ts/build/spine-widget.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spine-ts/build/spine-widget.js.map

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions spine-ts/webgl/src/SceneRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,70 @@ module spine.webgl {
this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
}

drawTextureUV (texture: GLTexture, x: number, y: number, width: number, height: number, u: number, v: number, u2: number, v2: number, color: Color = null) {
this.enableRenderer(this.batcher);
if (color === null) color = this.WHITE;
let quad = this.QUAD;
var i = 0;
quad[i++] = x;
quad[i++] = y;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = u;
quad[i++] = v;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x + width;
quad[i++] = y;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = u2;
quad[i++] = v;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x + width;
quad[i++] = y + height;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = u2;
quad[i++] = v2;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x;
quad[i++] = y + height;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = u;
quad[i++] = v2;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
}

drawTextureRotated (texture: GLTexture, x: number, y: number, width: number, height: number, pivotX: number, pivotY: number, angle: number, color: Color = null, premultipliedAlpha: boolean = false) {
this.enableRenderer(this.batcher);
if (color === null) color = this.WHITE;
Expand Down

0 comments on commit 246c531

Please sign in to comment.