Hi I recently started working on a 2d platformer game. I have used 2d opengl before but I had an issue with rendering tilemaps so I stopped working on that project and made a 3d game. After doing some 3d I now went back to 2d and I still have the same issue here is an image:
.
I am using nearest filtering and to create the tilemap I just get coordinates from a texture atlas class and apply them to the quads for each tile and put them into a vbo. The lines only appear if the camera is at certain positions:(no lines in this image)
.
Any help appreciated.
Code for texture atlas:
public class TextureAtlas {
private float[][] textureCoords;
public TextureAtlas(int width, int height) {
textureCoords= new float[width * height][];
float w = (float) 1d/width;
float h = (float) 1d/height;
int n = 0;
for(int i = 0;i<height;i++) {
for(int j = 0; j<width;j++) {
float offsetX = w*j;
float offsetY = h*i;
float[] coords = {
offsetX,h+offsetY,
offsetX,offsetY,
w+offsetX,h+offsetY,
offsetX,offsetY,
w+offsetX,h+offsetY,
w+offsetX,offsetY};
textureCoords[n] = coords;
n++;
}
}
}
public float[] getCoord(int textureNumber) {
return textureCoords[textureNumber];
}
}