Hello,
I have used my LWJGL engine in the past and had this problem: http://www.gamedev.net/topic/665122-lwjgl-gltranslatef-causes-texture-flicker/ . I couldn't solve it so I decided to move on to LibGDX. But now I have the exact same problem. I use Tiled map editor to make maps and OrthogonalTiledMapRenderer to draw it. But when I move the camera one of the colors on the map becomes lighter or something... Here's my code:
@Override
public void create() {
batch = new SpriteBatch();
cam = new OrthographicCamera();
cam.setToOrtho(false, WIDTH, HEIGHT);
cam.update();
map = new TmxMapLoader().load("res/town1.tmx");
renderer = new OrthogonalTiledMapRenderer(map);
playerTexture = new Texture(Gdx.files.internal("res/player.png"));
playerTextureRegions = new TextureRegion[4];
playerTextureRegions[0] = new TextureRegion(playerTexture, 0, 0, 16, 16);
playerTextureRegions[1] = new TextureRegion(playerTexture, 16, 0, 16,
16);
playerTextureRegions[2] = new TextureRegion(playerTexture, 32, 0, 16,
16);
playerTextureRegions[3] = new TextureRegion(playerTexture, 48, 0, 16,
16);
}
@Override
public void render() {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
if (Gdx.input.isKeyPressed(Keys.DOWN)) {
dir = 0;
pos.y -= 60.0f * Gdx.graphics.getDeltaTime();
}
if (Gdx.input.isKeyPressed(Keys.UP)) {
dir = 1;
pos.y += 60.0f * Gdx.graphics.getDeltaTime();
}
if (Gdx.input.isKeyPressed(Keys.RIGHT)) {
dir = 2;
pos.x += 60.0f * Gdx.graphics.getDeltaTime();
}
if (Gdx.input.isKeyPressed(Keys.LEFT)) {
dir = 3;
pos.x -= 60.0f * Gdx.graphics.getDeltaTime();
}
cam.position.set(pos.x + 8.0f, pos.y - 8.0f, 0.0f);
cam.update();
renderer.setView(cam);
renderer.render();
batch.setProjectionMatrix(cam.combined);
batch.begin();
batch.draw(playerTextureRegions[dir], pos.x, pos.y);
batch.end();
}
Is this a bug or a problem in my graphics card / drivers / etc...?
Thanks,
MatejaS