I would like to add support for tile rendering to SDL_Renderer. Is this a feature other people would use? I thought I’d ask here in case this is totally out of scope for SDL2. I have implemented this a couple of times on top of SDL and OpenGL, but it might make more sense to have this as part of SDL_Renderer.
My idea is a simple function to render a single tiled layer. (Maybe the map data should live in graphics memory too, like an SDL_Texture, but that would make the API more complex)
Tile maps can already be implemented on top of the current SDL_Renderer, but it could be much faster to implement them with shaders, so the tile rendering would have to be part of SDL2 itself. (Or maybe not, and batching is fast enough? Benchmarks will tell.) I can write software, GL, and GLES implementations, but I would probably need some help with the Metal backend.
I would propose an API that looks something like this:
struct SDL_TileSheet {
SDL_Texture* texture,
int tile_width;
int tile_height;
}
struct SDL_TileMap {
Uint16* data,
int columns;
int rows;
}
int SDL_RenderTiles(SDL_Renderer* renderer,
SDL_TileSheet* tilesheet,
SDL_TileMap* tilemap,
const SDL_Rect* srcrect,
const SDL_Rect* dstrect)
of course if the tile data lives on the GPU too, it would have to be similar to SDL_Texture and have a bunch of helper functions.