diff --git a/build.gradle b/build.gradle index 4494f28aad..d09ef15d71 100644 --- a/build.gradle +++ b/build.gradle @@ -244,6 +244,12 @@ project(":tools"){ dependencies{ compile project(":core") + + //for render tests + compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop" + + compile arcModule("backends:backend-lwjgl3") } } diff --git a/tools/build.gradle b/tools/build.gradle index 9afe633290..3b18ef99a7 100644 --- a/tools/build.gradle +++ b/tools/build.gradle @@ -351,6 +351,17 @@ task antialiasGen(){ } } +task testUpscale(dependsOn: classes, type: JavaExec){ + + if(System.getProperty("os.name").toLowerCase().contains("mac")){ + jvmArgs "-XstartOnFirstThread" + } + main = "io.anuke.mindustry.Upscaler" + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = "../core/assets/" +} + task genSprites(dependsOn: classes, type: JavaExec){ finalizedBy 'antialiasGen' diff --git a/tools/src/io/anuke/mindustry/SquareMarcher.java b/tools/src/io/anuke/mindustry/SquareMarcher.java index b25ad65443..ee755e8469 100644 --- a/tools/src/io/anuke/mindustry/SquareMarcher.java +++ b/tools/src/io/anuke/mindustry/SquareMarcher.java @@ -1,7 +1,8 @@ package io.anuke.mindustry; +import io.anuke.arc.Core; import io.anuke.arc.files.FileHandle; -import io.anuke.arc.graphics.Pixmap; +import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.graphics.glutils.FrameBuffer; import io.anuke.arc.util.*; @@ -16,7 +17,7 @@ public class SquareMarcher{ for(int x = 0; x < pixmap.getWidth(); x++){ for(int y = 0; y < pixmap.getHeight(); y++){ Tmp.c1.set(pixmap.getPixel(x, y)); - grid[x][pixmap.getHeight() - 1 - y] = Tmp.c1.a > 0.01f; + grid[x][y] = Tmp.c1.a > 0.01f; } } @@ -24,6 +25,8 @@ public class SquareMarcher{ Draw.proj().setOrtho(0, 0, resolution, resolution); buffer.begin(); + Core.graphics.clear(Color.BLACK); + Draw.color(Color.WHITE); float xscl = resolution / (float)pixmap.getWidth(), yscl = resolution / (float)pixmap.getHeight(); float scl = xscl; @@ -167,6 +170,7 @@ public class SquareMarcher{ } } + Draw.flush(); ScreenUtils.saveScreenshot(file, 0, 0, resolution, resolution); buffer.end(); } diff --git a/tools/src/io/anuke/mindustry/Upscaler.java b/tools/src/io/anuke/mindustry/Upscaler.java new file mode 100644 index 0000000000..f409035533 --- /dev/null +++ b/tools/src/io/anuke/mindustry/Upscaler.java @@ -0,0 +1,32 @@ +package io.anuke.mindustry; + +import io.anuke.arc.*; +import io.anuke.arc.backends.lwjgl3.*; +import io.anuke.arc.files.FileHandle; +import io.anuke.arc.graphics.Pixmap; +import io.anuke.arc.util.Log; +import io.anuke.mindustry.game.EventType.GameLoadEvent; + +public class Upscaler{ + + public static void main(String[] args){ + Events.on(GameLoadEvent.class, e -> scale()); + new Lwjgl3Application(new Mindustry(), new Lwjgl3ApplicationConfiguration()); + } + + static void scale(){ + FileHandle file = Core.files.local("../assets-raw/sprites/ui/icons"); + + SquareMarcher marcher = new SquareMarcher(); + + for(FileHandle img : file.list()){ + if(img.extension().equals("png")){ + marcher.render(new Pixmap(img), Core.files.external("images/").child(img.name())); + } + } + + Log.info("done."); + + Core.app.exit(); + } +}