PDA

View Full Version : How to best approach an OpenGL-based moving map



thahemp
09-09-2009, 02:58 PM
I've been at this for a while, and I can't seem to figure out the proper way to attack this project.

I am using SDL for my event loop, SDL_image for my texture loading, and OGR for my shapefile reading. Basically I have a shapefile tileindex with the tile names, and the lat/long coordinates of the 4 corners of a polygon representing the tile.

When the user drags the map, I update the coordinates and locate the proper tile in the tileindex using a point in polygon function. This works perfect for figuring out which tile should be in the center of the screen. Then I just grab the neighboring tiles to fill out the rest of my OpenGL polys.

The problem with this way is that every time the center tile changes, I have to re-texture all of my tiles. This is going to be too costly for the hardware. I know there is a better way to do it.

I have played with glTranslatef, but I can't seem to figure out what to do with the polys once they have moved off of the screen. I need to be able to reattach them to the other side of the tile set so they can cross the screen again with new textures loaded onto them.

I'm really just hoping someone has done something similar before and can point me in the right direction. Maybe my entire approach is dumb... I just haven't had enough experience with OpenGL.

Thanks in advance for any advice =)

tH