Hi all, I’m attempting to tile a texture in LibGDX with GL_REPEAT but when I render this, it stretches the image instead of repeating:
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
public class MyApp extends Game implements ApplicationListener {
public static final String LOG = "LOGIT";
protected Texture background;
protected SpriteBatch batch;
@Override
public void create() {
batch = new SpriteBatch();
background = ImageLoader.loadTexture("groundtile.png");
background.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
setScreen(new IntroScreen());
}
@Override
public void render() {
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
batch.begin();
batch.draw(background, 0, 0, w, h, 0, 0, w/128.0f, h/128.0f);
batch.end();
super.render();
}
}
I believe I do have the UV coordinates right in batch.draw(…) so what could be wrong?
Thanks in advance