use of com.badlogic.gdx.graphics.Texture in project libgdx by libgdx.
the class DecalTest method create.
@Override
public void create() {
Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
Gdx.gl.glDepthFunc(GL20.GL_LESS);
egg = new Texture(Gdx.files.internal("data/egg.png"));
egg.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
egg.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge);
wheel = new Texture(Gdx.files.internal("data/wheel.png"));
wheel.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
wheel.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge);
w = Gdx.graphics.getWidth() / 0.8f;
h = Gdx.graphics.getHeight() / 0.8f;
for (int i = 0; i < INITIAL_RENDERED; i++) {
toRender.add(makeDecal());
}
cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.near = 0.1f;
cam.far = 10f;
cam.position.set(0, 0, 0.1f);
cam.direction.set(0, 0, -1f);
batch = new DecalBatch(new CameraGroupStrategy(cam));
Gdx.gl.glClearColor(1, 1, 0, 1);
}
use of com.badlogic.gdx.graphics.Texture in project libgdx by libgdx.
the class DownloadTest method create.
@Override
public void create() {
batch = new SpriteBatch();
HttpRequest request = new HttpRequest(HttpMethods.GET);
request.setUrl("https://www.google.at/images/srpr/logo11w.png");
Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
@Override
public void handleHttpResponse(HttpResponse httpResponse) {
final byte[] bytes = httpResponse.getResult();
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
Pixmap pixmap = new Pixmap(bytes, 0, bytes.length);
texture = new Texture(new PixmapTextureData(pixmap, pixmap.getFormat(), false, false, true));
}
});
}
@Override
public void failed(Throwable t) {
t.printStackTrace();
Gdx.app.log("EmptyDownloadTest", "Failed", t);
}
@Override
public void cancelled() {
Gdx.app.log("EmptyDownloadTest", "Cancelled");
}
});
}
use of com.badlogic.gdx.graphics.Texture in project libgdx by libgdx.
the class DragAndDropTest method create.
public void create() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
final Skin skin = new Skin();
skin.add("default", new LabelStyle(new BitmapFont(), Color.WHITE));
skin.add("badlogic", new Texture("data/badlogic.jpg"));
Image sourceImage = new Image(skin, "badlogic");
sourceImage.setBounds(50, 125, 100, 100);
stage.addActor(sourceImage);
Image validTargetImage = new Image(skin, "badlogic");
validTargetImage.setBounds(200, 50, 100, 100);
stage.addActor(validTargetImage);
Image invalidTargetImage = new Image(skin, "badlogic");
invalidTargetImage.setBounds(200, 200, 100, 100);
stage.addActor(invalidTargetImage);
DragAndDrop dragAndDrop = new DragAndDrop();
dragAndDrop.addSource(new Source(sourceImage) {
public Payload dragStart(InputEvent event, float x, float y, int pointer) {
Payload payload = new Payload();
payload.setObject("Some payload!");
payload.setDragActor(new Label("Some payload!", skin));
Label validLabel = new Label("Some payload!", skin);
validLabel.setColor(0, 1, 0, 1);
payload.setValidDragActor(validLabel);
Label invalidLabel = new Label("Some payload!", skin);
invalidLabel.setColor(1, 0, 0, 1);
payload.setInvalidDragActor(invalidLabel);
return payload;
}
});
dragAndDrop.addTarget(new Target(validTargetImage) {
public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
getActor().setColor(Color.GREEN);
return true;
}
public void reset(Source source, Payload payload) {
getActor().setColor(Color.WHITE);
}
public void drop(Source source, Payload payload, float x, float y, int pointer) {
System.out.println("Accepted: " + payload.getObject() + " " + x + ", " + y);
}
});
dragAndDrop.addTarget(new Target(invalidTargetImage) {
public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
getActor().setColor(Color.RED);
return false;
}
public void reset(Source source, Payload payload) {
getActor().setColor(Color.WHITE);
}
public void drop(Source source, Payload payload, float x, float y, int pointer) {
}
});
}
use of com.badlogic.gdx.graphics.Texture in project libgdx by libgdx.
the class ETC1Test method create.
@Override
public void create() {
font = new BitmapFont();
camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
controller = new OrthoCamController(camera);
Gdx.input.setInputProcessor(controller);
Pixmap pixmap = new Pixmap(32, 32, Format.RGB565);
pixmap.setColor(1, 0, 0, 1);
pixmap.fill();
pixmap.setColor(0, 1, 0, 1);
pixmap.drawLine(0, 0, 32, 32);
pixmap.drawLine(0, 32, 32, 0);
ETC1Data encodedImage = ETC1.encodeImagePKM(pixmap);
pixmap.dispose();
pixmap = ETC1.decodeImage(encodedImage, Format.RGB565);
encodedImage.dispose();
img1 = new Texture(pixmap);
img2 = new Texture("data/test.etc1");
batch = new SpriteBatch();
pixmap.dispose();
}
use of com.badlogic.gdx.graphics.Texture in project libgdx by libgdx.
the class FilterPerformanceTest method create.
public void create() {
batch = new SpriteBatch();
sceneMatrix = new Matrix4().setToOrtho2D(0, 0, 480, 320);
textMatrix = new Matrix4().setToOrtho2D(0, 0, 480, 320);
atlas = new TextureAtlas(Gdx.files.internal("data/issue_pack"), Gdx.files.internal("data/"));
texture = new Texture(Gdx.files.internal("data/resource1.jpg"), true);
texture.setFilter(TextureFilter.MipMap, TextureFilter.Nearest);
setTextureFilter(0);
setModeString();
sprite = atlas.createSprite("map");
sprite2 = new Sprite(texture, 0, 0, 855, 480);
font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false);
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchDown(int x, int y, int pointer, int newParam) {
mode++;
if (mode == filters.length * 2)
mode = 0;
setTextureFilter(mode / 2);
setModeString();
return false;
}
});
}
Aggregations