adding gzip/replaced bad base64 impl with libgdx's

This commit is contained in:
minjaesong
2020-10-20 17:44:59 +09:00
parent ca672f23c2
commit f49cb6c300
9 changed files with 239 additions and 210 deletions

View File

@@ -6,12 +6,13 @@ Has no affiliation with OpenGL by Khronos Group
var GL = {};
// bytes should be able to handle both JSArray and Java ByteArray (toString = "[B")?
GL.Texture = function(w, h, bytes) {
this.width = w;
this.height = h;
this.texData = bytes;
if (!Array.isArray(bytes)) {
if (!Array.isArray(bytes) && !bytes.toString().startsWith("[B")) {
throw "Texture data is not an instance of array";
}
};
@@ -52,7 +53,7 @@ GL.drawTexPatternOver = function(texture, x, y, width, height) {
var tx = xx % texture.width;
var ty = yy % texture.height;
var c = texture.texData[ty * texture.width + tx];
if (c != 255) {
if (c != -1) {
graphics.plotPixel(x + xx, y + yy, c);
}
}
@@ -71,7 +72,7 @@ GL.drawTexImageOver = function(texture, x, y) {
for (var ty = 0; ty < texture.height; ty++) {
for (var tx = 0; tx < texture.width; tx++) {
var c = texture.texData[ty * texture.width + tx];
if (c != 255) {
if (c != -1) {
graphics.plotPixel(x + tx, y + ty, c);
}
}
@@ -93,7 +94,7 @@ GL.drawSpriteOver = function(sheet, xi, yi, x, y) {
for (var ty = 0; ty < sheet.tileHeight; ty++) {
for (var tx = 0; tx < sheet.tileWidth; tx++) {
var c = sheet.texture.texData[(ty + offy) * sheet.texture.width + (tx + offx)];
if (c != 255) {
if (c != -1) {
graphics.plotPixel(x + tx, y + ty, c);
}
}