So I have this java code,
public static void renderTileMap(int startX, int startY, int[][] map, int dwheelBuff) {
int size = dwheelBuff;
// Coordinate buffers, because we don't want for loop x, y to represent screen x, y
int coor_x = startX;
int coor_y = startY;
for(int y = 0; y < map.length; y++) {
coor_x = startX;
if(y > 0)
coor_y += size/2;
for(int x = 0; x < map[y].length; x++) {
if(x > 0)
coor_x += size/2;
renderTile(coor_x, coor_y, size);
}
}
}
private static void renderTile(int x1, int y1, int size) {
glBegin(GL_TRIANGLES);
double halfSize = size/2;
glVertex2d(x1 + halfSize, y1 + halfSize);
glVertex2d(x1 + halfSize, y1 - halfSize);
glVertex2d(x1 - halfSize, y1 - halfSize);
glVertex2d(x1 - halfSize, y1 - halfSize);
glVertex2d(x1 - halfSize, y1 + halfSize);
glVertex2d(x1 + halfSize, y1 + halfSize);
glEnd();
}
how can I set a view distance for this? Like, prevent the tiles from rendering offscreen