So in this video (about 8-10 seconds in), you’ll be able to see black lines that appear between rows of tiles for a split second. These definitely should not be there.
Fg3_Bd9AxKg
My rendering code is fairly simple. Here is my world renderer
public class WorldRenderer {
private World world;
private TiledMap map;
private TiledMapTileLayer layer;
private OrthogonalTiledMapRenderer renderer;
public WorldRenderer(World world) {
this.world = world;
map = new TiledMap();
layer = new TiledMapTileLayer(world.width, world.height, 16, 16);
map.getLayers().add(layer);
renderer = new OrthogonalTiledMapRenderer(map, 2F);
}
public void dispose() {
map.dispose();
}
public void render(float x, float y, float width, float height) {
for(int i = 0; i < world.dirtyChunks.length; i++) {
updateChunk(i);
}
OrthographicCamera cam = Game.instance.screenCam;
renderer.setView(cam);
renderer.render();
}
private void updateChunk(int chunk) {
if(!world.dirtyChunks[chunk]) {
return;
}
world.dirtyChunks[chunk] = false;
int x = world.getChunkStartX(chunk);
int y = world.getChunkStartY(chunk);
for(int iy = 0; iy < 16; iy++) {
for(int ix = 0; ix < 16; ix++) {
int tx = ix + x;
int ty = iy + y;
int tileID = world.tiles[tx + ty * world.width] & 0xFF;
Cell cell = layer.getCell(tx, ty);
if(cell == null) {
cell = new Cell();
layer.setCell(tx, ty, cell);
}
cell.setTile(Tile.TYPES[tileID].getMapTile());
}
}
}
}
and here is the code that calls it in the main render method of the program
public void render() {
//Input code goes here, just adjusts camX/camY
float width = Gdx.graphics.getWidth();
float height = Gdx.graphics.getHeight();
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
screenCam.setToOrtho(false, width, height);
screenCam.translate(camX, camY);
screenCam.update();
worldRenderer.render(0, 0, width, height);
}
I don’t run into these problems with the webgl backend. Also, I’m on Lubuntu (Linux) 64bit if that helps. How can I fix this?
EDIT: I was able to fix the problem by flooring camX and camY. I’m still interested in what caused it, wouldn’t a non integer value for the translation at most slightly distort the texture rather than causing those black lines?