use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class CpuSpriteBatchTest method create.
public void create() {
Batch batch = new CpuSpriteBatch();
// batch = new SpriteBatch();
stage = new Stage(new ExtendViewport(500, 500), batch);
Gdx.input.setInputProcessor(stage);
texture = new Texture("data/bobargb8888-32x32.png");
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
TextureRegionDrawable drawable = new TextureRegionDrawable(new TextureRegion(texture));
for (int i = 0; i < NUM_GROUPS; i++) {
Group group = createActorGroup(drawable);
stage.addActor(group);
}
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class CustomShaderSpriteBatchTest method create.
@Override
public void create() {
batch = new SpriteBatch(10);
ShaderProgram.pedantic = false;
shader = new ShaderProgram(Gdx.files.internal("data/shaders/batch.vert").readString(), Gdx.files.internal("data/shaders/batch.frag").readString());
batch.setShader(shader);
texture = new Texture("data/badlogic.jpg");
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch 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.g2d.SpriteBatch 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.g2d.SpriteBatch in project libgdx by libgdx.
the class EdgeDetectionTest method create.
public void create() {
ShaderProgram.pedantic = false;
/*
* shader = new ShaderProgram(Gdx.files.internal("data/shaders/default.vert").readString(), Gdx.files.internal(
* "data/shaders/depthtocolor.frag").readString()); if (!shader.isCompiled()) { Gdx.app.log("EdgeDetectionTest",
* "couldn't compile scene shader: " + shader.getLog()); }
*/
batchShader = new ShaderProgram(Gdx.files.internal("data/shaders/batch.vert").readString(), Gdx.files.internal("data/shaders/convolution.frag").readString());
if (!batchShader.isCompiled()) {
Gdx.app.log("EdgeDetectionTest", "couldn't compile post-processing shader: " + batchShader.getLog());
}
ObjLoader objLoader = new ObjLoader();
scene = objLoader.loadModel(Gdx.files.internal("data/scene.obj"));
sceneInstance = new ModelInstance(scene);
modelBatch = new ModelBatch();
fbo = new FrameBuffer(Format.RGB565, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(0, 0, 10);
cam.lookAt(0, 0, 0);
cam.far = 30;
batch = new SpriteBatch();
batch.setShader(batchShader);
fboRegion = new TextureRegion(fbo.getColorBufferTexture());
fboRegion.flip(false, true);
logger = new FPSLogger();
calculateOffsets();
}
Aggregations