1
General / Re: Visual glitch with a tilemap
« on: June 14, 2018, 11:21:06 pm »
Thanks for the reply. My view is setup with this code:
The view's size is not the same as the windows because of this.
So I should set the view's size to the window size and use sf::View::zoom instead of resizing it?
//Create Window
global.window.create(sf::VideoMode(window_base_width, window_base_height), PROJECT_TITLE, sf::Style::None);
{
//Setup Fullscreen
const float max_w = sf::VideoMode::getDesktopMode().width;
const float max_h = sf::VideoMode::getDesktopMode().height;
const float aspect = max_w / max_h;
float new_w, new_h;
if (max_w < max_h)
{
//Portrait display
new_w = std::min<float>(window_base_width, max_w);
new_h = new_w / aspect;
}
else
{
//Landscape display
new_h = std::min<float>(window_base_height, max_h);
new_w = new_h * aspect;
}
//Setup window view
sf::View view;
new_w = std::floor(new_w);
new_h = std::floor(new_h);
view.setSize(new_w, new_h);
view.setCenter(new_w/2, new_h/2);
global.window.setView(view);
//Window position and size
global.window.setSize(sf::Vector2u(max_w, max_h));
global.window.setPosition(sf::Vector2i(0, 0));
}
global.window.create(sf::VideoMode(window_base_width, window_base_height), PROJECT_TITLE, sf::Style::None);
{
//Setup Fullscreen
const float max_w = sf::VideoMode::getDesktopMode().width;
const float max_h = sf::VideoMode::getDesktopMode().height;
const float aspect = max_w / max_h;
float new_w, new_h;
if (max_w < max_h)
{
//Portrait display
new_w = std::min<float>(window_base_width, max_w);
new_h = new_w / aspect;
}
else
{
//Landscape display
new_h = std::min<float>(window_base_height, max_h);
new_w = new_h * aspect;
}
//Setup window view
sf::View view;
new_w = std::floor(new_w);
new_h = std::floor(new_h);
view.setSize(new_w, new_h);
view.setCenter(new_w/2, new_h/2);
global.window.setView(view);
//Window position and size
global.window.setSize(sf::Vector2u(max_w, max_h));
global.window.setPosition(sf::Vector2i(0, 0));
}
The view's size is not the same as the windows because of this.
So I should set the view's size to the window size and use sf::View::zoom instead of resizing it?