Skip to content

Instantly share code, notes, and snippets.

@jt0dd
Created September 9, 2018 19:11
Show Gist options
  • Select an option

  • Save jt0dd/d4e4be4a98443b0885d63f5ba9a0a003 to your computer and use it in GitHub Desktop.

Select an option

Save jt0dd/d4e4be4a98443b0885d63f5ba9a0a003 to your computer and use it in GitHub Desktop.
this.gpuDraw = this.gpu
.createKernel(function(buffer, sprite, x, y, w, h, bufferWidth) {
var subBufferWidth = w * 4;
var cy = Math.floor(this.thread.x / bufferWidth);
var cx = this.thread.x % bufferWidth;
var dx = x - cx;
var dy = y - cy;
var dz = this.thread.x % 4;
if (dx > 0 && dx < w && dy > 0 && dy < h) {
//console.log(dx, dy, dz); //these are logging fine btw
return sprite[0][0][0];
} else {
return buffer[this.thread.x];
}
})
.setOutput([this.smallWidth * this.smallHeight * 4]);
this.buffer = this.gpuDraw(
bufferCopy,
entity.sprite,
entity.x,
entity.y,
entity.w,
entity.h,
this.bufferWidth
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment