use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class PngTest method create.
public void create() {
batch = new SpriteBatch();
badlogic = new Texture(Gdx.files.internal("data/badlogic.jpg"));
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class TextButtonTest method render.
@Override
public void render() {
Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.draw();
Gdx.app.log("X", "FPS: " + Gdx.graphics.getFramesPerSecond());
SpriteBatch spriteBatch = (SpriteBatch) stage.getBatch();
Gdx.app.log("X", "render calls: " + spriteBatch.totalRenderCalls);
spriteBatch.totalRenderCalls = 0;
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class TextInputDialogTest method create.
public void create() {
message = "Touch screen for dialog";
batch = new SpriteBatch();
font = new BitmapFont();
Gdx.input.getTextInput(new TextInputListener() {
@Override
public void input(String text) {
message = "message: " + text + ", touch screen for new dialog";
}
@Override
public void canceled() {
message = "cancled by user";
}
}, "enter something funny", "funny", "something funny");
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class TextureDownloadTest method create.
@Override
public void create() {
new Thread(new Runnable() {
/** Downloads the content of the specified url to the array. The array has to be big enough. */
private int download(byte[] out, String url) {
InputStream in = null;
try {
HttpURLConnection conn = null;
conn = (HttpURLConnection) new URL(url).openConnection();
conn.setDoInput(true);
conn.setDoOutput(false);
conn.setUseCaches(true);
conn.connect();
in = conn.getInputStream();
int readBytes = 0;
while (true) {
int length = in.read(out, readBytes, out.length - readBytes);
if (length == -1)
break;
readBytes += length;
}
return readBytes;
} catch (Exception ex) {
return 0;
} finally {
StreamUtils.closeQuietly(in);
}
}
@Override
public void run() {
// assuming the content is not bigger than 200kb.
byte[] bytes = new byte[200 * 1024];
int numBytes = download(bytes, "http://www.badlogicgames.com/wordpress/wp-content/uploads/2012/01/badlogic-new.png");
if (numBytes != 0) {
// load the pixmap, make it a power of two if necessary (not needed for GL ES 2.0!)
Pixmap pixmap = new Pixmap(bytes, 0, numBytes);
final int originalWidth = pixmap.getWidth();
final int originalHeight = pixmap.getHeight();
int width = MathUtils.nextPowerOfTwo(pixmap.getWidth());
int height = MathUtils.nextPowerOfTwo(pixmap.getHeight());
final Pixmap potPixmap = new Pixmap(width, height, pixmap.getFormat());
potPixmap.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight());
pixmap.dispose();
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
image = new TextureRegion(new Texture(potPixmap), 0, 0, originalWidth, originalHeight);
}
});
}
}
}).start();
font = new BitmapFont();
batch = new SpriteBatch();
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class TextureFormatTest method create.
@Override
public void create() {
FileHandle file = Gdx.files.internal("data/bobargb8888-32x32.png");
nonMipMapped[0] = new Texture(file, Format.Alpha, false);
nonMipMapped[1] = new Texture(file, Format.LuminanceAlpha, false);
nonMipMapped[2] = new Texture(file, Format.RGB888, false);
nonMipMapped[3] = new Texture(file, Format.RGB565, false);
nonMipMapped[4] = new Texture(file, Format.RGBA8888, false);
nonMipMapped[5] = new Texture(file, Format.RGBA4444, false);
mipMapped[0] = new Texture(file, Format.Alpha, true);
mipMapped[1] = new Texture(file, Format.LuminanceAlpha, true);
mipMapped[2] = new Texture(file, Format.RGB888, true);
mipMapped[3] = new Texture(file, Format.RGB565, true);
mipMapped[4] = new Texture(file, Format.RGBA8888, true);
mipMapped[5] = new Texture(file, Format.RGBA4444, true);
batch = new SpriteBatch();
}
Aggregations