Skip to content

Commit

Permalink
Revert "Test for new fonts, 16 sampling, maybe killer for performance…
Browse files Browse the repository at this point in the history
…, lets see how it goes. DFF for zooming fonts."

This reverts commit 3740018.
  • Loading branch information
azakhary committed Nov 24, 2019
1 parent 3740018 commit f7d741a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 264 deletions.
199 changes: 0 additions & 199 deletions editor/assets/skin/roboto-dff.fnt

This file was deleted.

Binary file removed editor/assets/skin/roboto-dff.png
Binary file not shown.
2 changes: 1 addition & 1 deletion editor/assets/skin/uiskin.atlas
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
uiskin.png
size: 2048,1024
format: RGBA8888
filter: Linear,Linear
filter: Nearest,Nearest
repeat: none
background-fill
rotate: false
Expand Down
7 changes: 5 additions & 2 deletions editor/assets/skin/uiskin.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{

com.badlogic.gdx.graphics.g2d.BitmapFont: {
default-font: { file: skin/default-font.fnt },
small-font: { file: skin/small-font.fnt }
},
com.badlogic.gdx.graphics.Color: {
black: {a: 1, b: 0, g: 0, r: 0 }
white: {a: 1, b: 1, g: 1, r: 1 }
Expand Down Expand Up @@ -265,4 +268,4 @@
com.kotcrab.vis.ui.util.adapter.SimpleListAdapter$SimpleListAdapterStyle: {
default: {background: window-bg, selection: list-selection }
}
}
}
2 changes: 0 additions & 2 deletions editor/src/com/rockbite/tools/talos/TalosLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public static void main (String[] arg) {
config.setWindowedMode(1200, 700);
config.setTitle("Talos");

config.setBackBufferConfig(8, 8, 8, 8, 16, 0, 16);

TalosMain talos = new TalosMain();

new Lwjgl3Application(talos, config);
Expand Down
61 changes: 1 addition & 60 deletions editor/src/com/rockbite/tools/talos/TalosMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.BitmapFontCache;
import com.badlogic.gdx.graphics.g2d.DistanceFieldFont;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.utils.ObjectMap;
import com.kotcrab.vis.ui.VisUI;
Expand Down Expand Up @@ -141,27 +134,9 @@ public void run () {
preferences = Gdx.app.getPreferences("talos-preferences");

TextureAtlas atlas = new TextureAtlas(Gdx.files.internal("skin/uiskin.atlas"));
skin = new Skin();
skin = new Skin(Gdx.files.internal("skin/uiskin.json"));
skin.addRegions(atlas);

Texture fontTexture = new Texture(Gdx.files.internal("skin/roboto-dff.png"), true);
fontTexture.setFilter(Texture.TextureFilter.MipMapLinearNearest, Texture.TextureFilter.Linear);
DistanceFieldFont distanceFieldFont = new DistanceFieldFont(Gdx.files.internal("skin/roboto-dff.fnt"), new TextureRegion(fontTexture)) {

@Override
public BitmapFontCache newFontCache () {
return new CustomCache(this, this.usesIntegerPositions());
}
};
distanceFieldFont.setDistanceFieldSmoothing(10);
distanceFieldFont.setUseIntegerPositions(true);

skin.add("default-font", distanceFieldFont, BitmapFont.class);
skin.add("small-font", distanceFieldFont, BitmapFont.class);

skin.load(Gdx.files.internal("skin/uiskin.json"));


VisUI.load(skin);

uiStage = new UIStage(skin);
Expand All @@ -183,40 +158,6 @@ public BitmapFontCache newFontCache () {
TalosMain.Instance().ProjectController().newProject(ProjectController.TLS);
}


static private class CustomCache extends BitmapFontCache {

private final ShaderProgram distanceFieldShader;

public CustomCache (DistanceFieldFont font, boolean integer) {
super(font, integer);
distanceFieldShader = DistanceFieldFont.createDistanceFieldShader();
}

private float getSmoothingFactor () {
final DistanceFieldFont font = (DistanceFieldFont)super.getFont();
return font.getDistanceFieldSmoothing() * font.getScaleX();
}

@Override
public void draw (Batch spriteBatch) {
final ShaderProgram cache = spriteBatch.getShader();
spriteBatch.setShader(distanceFieldShader);
spriteBatch.getShader().setUniformf("u_smoothing", getSmoothingFactor());
super.draw(spriteBatch);
spriteBatch.setShader(cache);
}

@Override
public void draw (Batch spriteBatch, int start, int end) {
final ShaderProgram cache = spriteBatch.getShader();
spriteBatch.setShader(distanceFieldShader);
spriteBatch.getShader().setUniformf("u_smoothing", getSmoothingFactor());
super.draw(spriteBatch, start, end);
spriteBatch.setShader(cache);
}
}

public void disableNodeStage() {
currentWorkplaceStage = null;
inputMultiplexer.removeProcessor(nodeStage.getStage());
Expand Down

0 comments on commit f7d741a

Please sign in to comment.