use of com.badlogic.gdx.graphics.Texture in project libgdx by libgdx.
the class Box2DTest method create.
@Override
public void create() {
// setup the camera. In Box2D we operate on a
// meter scale, pixels won't do it. So we use
// an orthographic camera with a viewport of
// 48 meters in width and 32 meters in height.
// We also position the camera so that it
// looks at (0,16) (that's where the middle of the
// screen will be located).
camera = new OrthographicCamera(48, 32);
camera.position.set(0, 16, 0);
// next we setup the immediate mode renderer
renderer = new ShapeRenderer();
// next we create the box2d debug renderer
debugRenderer = new Box2DDebugRenderer();
// next we create a SpriteBatch and a font
batch = new SpriteBatch();
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
font.setColor(Color.RED);
textureRegion = new TextureRegion(new Texture(Gdx.files.internal("data/badlogicsmall.jpg")));
// next we create out physics world.
createPhysicsWorld();
// register ourselfs as an InputProcessor
Gdx.input.setInputProcessor(this);
}
use of com.badlogic.gdx.graphics.Texture in project libgdx by libgdx.
the class Bresenham2Test method create.
@Override
public void create() {
Pixmap pixmap = new Pixmap(512, 512, Format.RGBA8888);
pixmap.setColor(Color.WHITE);
Bresenham2 bresenham = new Bresenham2();
for (GridPoint2 point : bresenham.line(0, 0, 512, 512)) pixmap.drawPixel(point.x, point.y);
for (GridPoint2 point : bresenham.line(512, 0, 0, 512)) pixmap.drawPixel(point.x, point.y);
for (GridPoint2 point : bresenham.line(0, 0, 512, 256)) pixmap.drawPixel(point.x, point.y);
for (GridPoint2 point : bresenham.line(512, 0, 0, 256)) pixmap.drawPixel(point.x, point.y);
result = new Texture(pixmap);
batch = new SpriteBatch();
}
use of com.badlogic.gdx.graphics.Texture in project libgdx by libgdx.
the class BitmapFontAlignmentTest method create.
@Override
public void create() {
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchDown(int x, int y, int pointer, int newParam) {
renderMode = (renderMode + 1) % 6;
return false;
}
});
spriteBatch = new SpriteBatch();
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
logoSprite = new Sprite(texture);
logoSprite.setColor(1, 1, 1, 0.6f);
logoSprite.setBounds(50, 100, 400, 100);
font = new BitmapFont(Gdx.files.getFileHandle("data/verdana39.fnt", FileType.Internal), Gdx.files.getFileHandle("data/verdana39.png", FileType.Internal), false);
cache = font.newFontCache();
layout = new GlyphLayout();
}
use of com.badlogic.gdx.graphics.Texture in project libgdx by libgdx.
the class BitmapFontFlipTest method create.
@Override
public void create() {
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchDown(int x, int y, int pointer, int newParam) {
renderMode = (renderMode + 1) % 4;
return false;
}
});
spriteBatch = new SpriteBatch();
spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, 0, 1));
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
logoSprite = new Sprite(texture);
logoSprite.flip(false, true);
logoSprite.setPosition(0, 320 - 256);
logoSprite.setColor(1, 1, 1, 0.5f);
font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), Gdx.files.internal("data/verdana39.png"), true);
cache1 = font.newFontCache();
cache2 = font.newFontCache();
cache3 = font.newFontCache();
cache4 = font.newFontCache();
cache5 = font.newFontCache();
createCaches("cached", cache1, cache2, cache3, cache4, cache5);
font.getData().setScale(1.33f);
cacheScaled1 = font.newFontCache();
cacheScaled2 = font.newFontCache();
cacheScaled3 = font.newFontCache();
cacheScaled4 = font.newFontCache();
cacheScaled5 = font.newFontCache();
createCaches("cache scaled", cacheScaled1, cacheScaled2, cacheScaled3, cacheScaled4, cacheScaled5);
}
use of com.badlogic.gdx.graphics.Texture in project libgdx by libgdx.
the class Gdx2DTest method textureFromPixmap.
Texture textureFromPixmap(Gdx2DPixmap pixmap) {
Texture texture = new Texture(pixmap.getWidth(), pixmap.getHeight(), Format.RGB565);
texture.bind();
Gdx.gl.glTexImage2D(GL20.GL_TEXTURE_2D, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
return texture;
}
Aggregations