Hello !
I’m working on a project where I’m trying to render a tilemap with a texture atlas. Until now, it works good but I just enable full screen window, and I want my tilemap fill the maximum of the window by zooming in. Instead of manually compute positions and sizes of images with a zoom value, I have found the function SDL_RenderSetLogicalSize that can do all this for me. My code is now like this :
void Window::CreateWindow()
{
m_window = SDL_CreateWindow(m_title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 0, 0,
m_renderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED);
SDL_RenderSetLogicalSize(m_renderer, m_width, m_height);
}
I can just now specify the dimension of the grid of tiles I want, and it’s working :
Window::Window(const std::string& title, const int grid_width, const int grid_height, const SDL_Color bg_color) :
{
m_width = grid_width*32; // 32 is my tile size
m_height = grid_height*32;
InitSdl();
CreateWindow();
}
Ok great, but now I have sometimes strange vertical lines that appears between two tiles :
I’m almost sure my problems is related to conversion from float to int, because of the scale factor. Using this line resolve the problem (but the scaling is not enough to fill the window, so I can’t avoid using a float I guess).
SDL_RenderSetIntegerScale(renderer, SDL_TRUE);
Is it a common problem ? I think I’m doing something wrong…
You can look the code here : Atlacp/src at main · Loick01/Atlacp · GitHub
Thanks





