I have create a texture with my game map
SDL_SetRenderTarget(_game->renderer(), _texture);
for(int x = 0; x < _width; ++x)
{
for(int y = 0; y < _height; ++y)
{
int tile = _data[(x * _width) + y];
SDL_Rect target {static_cast<int>((x * 32)), static_cast<int>((y * 32)), 32, 32 };
SDL_RenderCopyEx(_game->renderer(), _tiles[tile], &_source, &target, 0, 0, SDL_FLIP_NONE);
}
}
SDL_SetRenderTarget(_game->renderer(), 0)
Then each time I render I copy the relevant portion
void render()
{
auto camera = _game->getCamera()->position();
SDL_Rect source { static_cast<int>(camera.x), static_cast<int>(camera.y), 800, 600};
SDL_Rect target { 0, 0, 800, 600 };
SDL_RenderCopyEx(_game->renderer(), _texture, &source, &target, 0, 0, SDL_FLIP_NONE);
}
But when the player moves horizontally, there is an odd effect in vertical lines, like if you notice they are redrawn and they are not totally vertical.
Any ideas how to avoid this effect