Tile Map Tile location/size issue

The tiles render with line breaks every few tiles. The breaks only occur along the X axis.

Render Code:


		GL11.glPushMatrix();
			int tileWidth = 16;
			int tileHeight = 16;
			int left = camera.x;
			int top = camera.y;
			
			
			for (int x = left / tileWidth; x < (left / tileWidth) + (camera.width / tileWidth) + 2; x++)
			{
				for (int y = top / tileHeight; y < (top / tileHeight) + (camera.height / tileHeight) + 2; y++)
				{
					//left / tilewidth
					if (testMap.getTile(x,y) != null)
					{
						int color = testMap.getTile(x, y).color;
						GL11.glColor3f(((color & 0xFF0000) >> 16) / 255, ((color & 0xFF00) >> 8) / 255, (color & 0xFF) / 255);
						
						GL11.glBegin(GL11.GL_QUADS);
						int ox = x - (left/tileWidth) - 1;
						int oy = y - (top/tileHeight) - 1;
						int x1 = ox * tileWidth;
						int y1 = oy * tileHeight;
						int x2 = x1 + tileWidth;
						int y2 = y1 + tileHeight;

						GL11.glVertex2f(x1, y1);
						GL11.glVertex2f(x2, y1);
						GL11.glVertex2f(x2, y2);
						GL11.glVertex2f(x1, y2);
						GL11.glEnd();
					}
				}
			}	
		GL11.glPopMatrix();

Line Breaks:

Imgur

Tile is probably null there.

Thanks. I was so sure the problem was with rendering that I didnt bother checking the way i get the tile from the chunk. I got it working now though.

Just a suggestion, move the glBegin and end out of the loop. Right now you’re calling each many more times than you need to which (I think) would reduce performance a little bit. No big deal though!