Render tests
This commit is contained in:
@@ -244,6 +244,12 @@ project(":tools"){
|
|||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
compile project(":core")
|
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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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){
|
task genSprites(dependsOn: classes, type: JavaExec){
|
||||||
finalizedBy 'antialiasGen'
|
finalizedBy 'antialiasGen'
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package io.anuke.mindustry;
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.files.FileHandle;
|
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.g2d.*;
|
||||||
import io.anuke.arc.graphics.glutils.FrameBuffer;
|
import io.anuke.arc.graphics.glutils.FrameBuffer;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
@@ -16,7 +17,7 @@ public class SquareMarcher{
|
|||||||
for(int x = 0; x < pixmap.getWidth(); x++){
|
for(int x = 0; x < pixmap.getWidth(); x++){
|
||||||
for(int y = 0; y < pixmap.getHeight(); y++){
|
for(int y = 0; y < pixmap.getHeight(); y++){
|
||||||
Tmp.c1.set(pixmap.getPixel(x, 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);
|
Draw.proj().setOrtho(0, 0, resolution, resolution);
|
||||||
|
|
||||||
buffer.begin();
|
buffer.begin();
|
||||||
|
Core.graphics.clear(Color.BLACK);
|
||||||
|
Draw.color(Color.WHITE);
|
||||||
float xscl = resolution / (float)pixmap.getWidth(), yscl = resolution / (float)pixmap.getHeight();
|
float xscl = resolution / (float)pixmap.getWidth(), yscl = resolution / (float)pixmap.getHeight();
|
||||||
float scl = xscl;
|
float scl = xscl;
|
||||||
|
|
||||||
@@ -167,6 +170,7 @@ public class SquareMarcher{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Draw.flush();
|
||||||
ScreenUtils.saveScreenshot(file, 0, 0, resolution, resolution);
|
ScreenUtils.saveScreenshot(file, 0, 0, resolution, resolution);
|
||||||
buffer.end();
|
buffer.end();
|
||||||
}
|
}
|
||||||
|
|||||||
32
tools/src/io/anuke/mindustry/Upscaler.java
Normal file
32
tools/src/io/anuke/mindustry/Upscaler.java
Normal file
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user