use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.
the class FreeTypeDisposeTest method render.
public void render() {
if (Gdx.input.justTouched()) {
for (int i = 0; i < 10; i++) {
if (font != null) {
font.dispose();
}
FileHandle fontFile = Gdx.files.internal("data/arial.ttf");
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 15;
font = generator.generateFont(parameter);
generator.dispose();
}
for (int i = 0; i < 10; i++) System.gc();
Gdx.app.log("FreeTypeDisposeTest", "generated 10 fonts");
Gdx.app.log("FreeTypeDisposeTest", Gdx.app.getJavaHeap() + ", " + Gdx.app.getNativeHeap());
}
}
use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.
the class FreeTypeTest method create.
@Override
public void create() {
boolean flip = false;
batch = new SpriteBatch();
if (flip) {
OrthographicCamera cam = new OrthographicCamera();
cam.setToOrtho(flip);
cam.update();
batch.setProjectionMatrix(cam.combined);
}
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), flip);
FileHandle fontFile = Gdx.files.internal("data/arial.ttf");
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 15;
parameter.flip = flip;
parameter.genMipMaps = true;
// parameter.shadowOffsetX = 1;
// parameter.shadowOffsetY = 1;
// parameter.shadowColor = Color.GREEN;
// parameter.borderWidth = 1f;
// parameter.borderColor = Color.PURPLE;
FreeTypeBitmapFontData fontData = generator.generateData(parameter);
ftFont = generator.generateFont(parameter);
generator.dispose();
}
use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.
the class ShaderCollectionTest method setEnvironment.
public void setEnvironment(String name) {
if (name == null)
return;
if (cubemap != null) {
cubemap.dispose();
cubemap = null;
}
if (name.equals("<none>")) {
if (environment.has(CubemapAttribute.EnvironmentMap)) {
environment.remove(CubemapAttribute.EnvironmentMap);
shaderProvider.clear();
}
} else {
FileHandle root = Gdx.files.internal("data/g3d/environment");
FacedCubemapData faces = new FacedCubemapData(root.child(name + "_PX.png"), root.child(name + "_NX.png"), root.child(name + "_PY.png"), root.child(name + "_NY.png"), root.child(name + "_PZ.png"), root.child(name + "_NZ.png"), // FIXME mipmapping on desktop
false);
cubemap = new Cubemap(faces);
faces.load(CubemapSide.NegativeX, root.child(name + "_NX.png"));
cubemap.load(faces);
if (!environment.has(CubemapAttribute.EnvironmentMap))
shaderProvider.clear();
environment.set(new CubemapAttribute(CubemapAttribute.EnvironmentMap, cubemap));
}
}
use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.
the class GwtBinaryTest method create.
@Override
public void create() {
FileHandle handle = Gdx.files.internal("data/arial.ttf");
bytes = new byte[(int) handle.length()];
DataInputStream in = new DataInputStream(handle.read());
for (int i = 0; i < 100; i++) {
try {
bytes[i] = in.readByte();
} catch (IOException e) {
e.printStackTrace();
}
}
}
use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.
the class AssetsFileGenerator method main.
public static void main(String[] args) {
FileHandle file = new FileHandle(args[0]);
StringBuffer list = new StringBuffer();
args[0] = args[0].replace("\\", "/");
if (!args[0].endsWith("/"))
args[0] = args[0] + "/";
traverse(file, args[0], list);
new FileHandle(args[0] + "/assets.txt").writeString(list.toString(), false);
}
Aggregations