Large Non-Square textures

I’m using OpenGL to draw a city map in a 2D game. The player can zoom out, to see most of the city, or zoom way in, to see individual people walking around the city.

The city map is stored on disk simply as a single large texture, with possibly non-power-of-two dimensions. My strategy was to break up the image into NxN squares and render each square as a quad.

This looks fine for nearest-neighbor magnification, but when i switch to linear magnification, I get ugly artifacts at the edges of the tiles.

I assume this is because the linear filter is doing a weighted average of the nearest four texels, and since I’ve split the image into tiles there is a discontinuity between the texels available on one side of a tile boundary and those on the other.

I think I could solve the problem by adding a 1 pixel border around the tile texture, but this seems very wasteful.

My question is, what’s a good way to manage the display of very large images like this?
The map images themselves are sizes around 1200x1200.


Hmmm, I’m not sure how filtering would affect this, but perhaps if you set your texture wrap mode to GL_CLAMP_TO_EDGE_EXT it would work better?

Just an idea, if I’m wrong I’m sure someone else will have a better suggestion.

Thanks a lot!

I tried GL_CLAMP and GL_CLAMP_TO_EDGE (my headers don’t have a GL_CLAMP_TO_EDGE_EXT). Both give the same output, but both look much better than the default GL_REPEAT.

It looks like this solved half of the problem. I still have a smaller but still visually intrusive discontinuity there.

I’m going to solve this using the solution I outlined earlier unless anyone has interesting suggestions on dealing with displaying large images like this.

On a related note, are there any guidelines for optimizing the number of textures and their sizes for best use of texture memory? Or is this something that the driver will handle and rearrange on it’s own?