How to implement an infinite map with pan/zoom?

Hi there,

I’d like to implement an infinite map with the possibility to navigate while panning around and zooming in/out with the mouse.

The objects to be drawn will have x,y coordinates on the map and a connection to a SDL_Texture (with sprite animation).

But I still wonder how to implement the rendering part…

Basically, I will have a SDL_Rect representing the camera view/rectangle in my logicial world/map. And I have to draw what is visible inside this part of the map to the window/renderer.

I think about using an intermediate rendering to a texture that will have the size of the camera rectangle, and then rendering this texture to the window, letting SDL doing the scaling job.

The problem is that depending on the zoom factor, the area of the camera rectangle will change, and the size of this intermediate texture will change too… I guess I cannot recreate this texture every time the user is changing the zoom…

Any idea how to do this efficiently using SDL ? Any example around here ?