Created
September 9, 2018 19:11
-
-
Save jt0dd/d4e4be4a98443b0885d63f5ba9a0a003 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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