Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17063

OpenGL prevent tiles from rendering offscreen

$
0
0

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 …

Viewing all articles
Browse latest Browse all 17063

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>