Here's a small part of screenshot that shows issue. On top is original, second is resized by my app. (4-th line of text is distorted)
Here is a minimal code
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;
int main(){
sf::RenderWindow App(sf::VideoMode(800, 765, 32), "Fail");
sf::View View( App.GetDefaultView().GetHalfSize(),App.GetDefaultView().GetHalfSize() );
sf::Image ibackground;
ibackground.LoadFromFile("test.png");
ibackground.SetSmooth(false);
sf::Sprite background;
background.SetImage(ibackground);
while (App.IsOpened()){
sf::Event Event;
while (App.GetEvent(Event)){
if (Event.Type == sf::Event::Closed)
App.Close();
if( Event.Type == sf::Event::Resized )
{
View.SetHalfSize( Event.Size.Width /2, Event.Size.Height /2 );
View.SetCenter( Event.Size.Width /2, Event.Size.Height /2 );
App.GetDefaultView().SetHalfSize( View.GetHalfSize() );
App.GetDefaultView().SetCenter( View.GetCenter() );
cout<<Event.Size.Width<<" "<<Event.Size.Height<<endl;
cout<<"Center: "<<View.GetCenter().x<<" "<<View.GetCenter().y<<endl;
}
}
App.Clear();
App.SetView(View);
App.Draw(background);
App.SetView( App.GetDefaultView() );
App.Display();
}
return 0;
}
Now that I tried to prepare a minimal code, I see that when application start having odd height image behave normal. But when I try to resize on y axis some distortion appear. So probably my Event::Resized is guilty
I have also another question. My desktop have 1600x900 px, when I try to set VideoMode() in above code to this:
sf::RenderWindow App(sf::VideoMode(1600, 900, 32), "test");
After run, my application enter twice Evet::Resized.
first with:
Event.Size.Width = 1592 and Event.Size.Height = 822
and second with what was set in sf::VideoMode()
Event.Size.Width = 1600 and Event.Size.Height = 900
Why it is like that ?